object Instant extends Serializable
- Annotations
- @SerialVersionUID()
- Alphabetic
- By Inheritance
- Instant
- Serializable
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##(): Int
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- val EPOCH: Instant
Constant for the 1970-01-01T00:00:00Z epoch instant.
- val MAX: Instant
The maximum supported
Instant
, '1000000000-12-31T23:59:59.999999999Z'.The maximum supported
Instant
, '1000000000-12-31T23:59:59.999999999Z'. This could be used by an application as a "far future" instant.This is one year later than the maximum
LocalDateTime
. This provides sufficient values to handle the range ofZoneOffset
which affect the instant in addition to the local date-time. The value is also chosen such that the value of the year fits in anint
. - val MIN: Instant
The minimum supported
Instant
, '-1000000000-01-01T00:00Z'.The minimum supported
Instant
, '-1000000000-01-01T00:00Z'. This could be used by an application as a "far past" instant.This is one year earlier than the minimum
LocalDateTime
. This provides sufficient values to handle the range ofZoneOffset
which affect the instant in addition to the local date-time. The value is also chosen such that the value of the year fits in anint
. - final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def clone(): AnyRef
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native()
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- def finalize(): Unit
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable])
- def from(temporal: TemporalAccessor): Instant
Obtains an instance of
Instant
from a temporal object.Obtains an instance of
Instant
from a temporal object.A
TemporalAccessor
represents some form of date and time information. This factory converts the arbitrary temporal object to an instance ofInstant
.The conversion extracts the
INSTANT_SECONDS
andNANO_OF_SECOND
fields.This method matches the signature of the functional interface
TemporalQuery
allowing it to be used as a query via method reference,Instant::from
.- temporal
the temporal object to convert, not null
- returns
the instant, not null
- Exceptions thrown
DateTimeException
if unable to convert to an { @code Instant}
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- def now(clock: Clock): Instant
Obtains the current instant from the specified clock.
Obtains the current instant from the specified clock.
This will query the specified clock to obtain the current time.
Using this method allows the use of an alternate clock for testing. The alternate clock may be introduced using
dependency injection
.- clock
the clock to use, not null
- returns
the current instant, not null
- def now: Instant
Obtains the current instant from the system clock.
Obtains the current instant from the system clock.
This will query the
system UTC clock
to obtain the current instant.Using this method will prevent the ability to use an alternate time-source for testing because the clock is effectively hard-coded.
- returns
the current instant using the system clock, not null
- def ofEpochMilli(epochMilli: Long): Instant
Obtains an instance of
Instant
using milliseconds from the epoch of 1970-01-01T00:00:00Z.Obtains an instance of
Instant
using milliseconds from the epoch of 1970-01-01T00:00:00Z.The seconds and nanoseconds are extracted from the specified milliseconds.
- epochMilli
the number of milliseconds from 1970-01-01T00:00:00Z
- returns
an instant, not null
- Exceptions thrown
DateTimeException
if the instant exceeds the maximum or minimum instant
- def ofEpochSecond(epochSecond: Long, nanoAdjustment: Long): Instant
Obtains an instance of
Instant
using seconds from the epoch of 1970-01-01T00:00:00Z and nanosecond fraction of second.Obtains an instance of
Instant
using seconds from the epoch of 1970-01-01T00:00:00Z and nanosecond fraction of second.This method allows an arbitrary number of nanoseconds to be passed in. The factory will alter the values of the second and nanosecond in order to ensure that the stored nanosecond is in the range 0 to 999,999,999. For example, the following will result in the exactly the same instant:
Instant.ofSeconds(3, 1); Instant.ofSeconds(4, -999_999_999); Instant.ofSeconds(2, 1000_000_001);
- epochSecond
the number of seconds from 1970-01-01T00:00:00Z
- nanoAdjustment
the nanosecond adjustment to the number of seconds, positive or negative
- returns
an instant, not null
- Exceptions thrown
ArithmeticException
if numeric overflow occursDateTimeException
if the instant exceeds the maximum or minimum instant
- def ofEpochSecond(epochSecond: Long): Instant
Obtains an instance of
Instant
using seconds from the epoch of 1970-01-01T00:00:00Z.Obtains an instance of
Instant
using seconds from the epoch of 1970-01-01T00:00:00Z.The nanosecond field is set to zero.
- epochSecond
the number of seconds from 1970-01-01T00:00:00Z
- returns
an instant, not null
- Exceptions thrown
DateTimeException
if the instant exceeds the maximum or minimum instant
- def parse(text: CharSequence): Instant
Obtains an instance of
Instant
from a text string such as2007-12-03T10:15:30.000Z
.Obtains an instance of
Instant
from a text string such as2007-12-03T10:15:30.000Z
.The string must represent a valid instant in UTC and is parsed using
DateTimeFormatter#ISO_INSTANT
.- text
the text to parse, not null
- returns
the parsed instant, not null
- Exceptions thrown
DateTimeParseException
if the text cannot be parsed
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toString(): String
- Definition Classes
- AnyRef → Any
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()