Constant for the 1970-01-01T00:00:00Z epoch 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 of ZoneOffset
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
an int
.
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 of ZoneOffset
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
an int
.
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 of Instant
.
The conversion extracts the INSTANT_SECONDS
and NANO_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
.
the temporal object to convert, not null
the instant, not null
DateTimeException
if unable to convert to an { @code 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
.
the clock to use, not null
the current instant, not null
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.
the current instant using the system clock, not null
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.
the number of milliseconds from 1970-01-01T00:00:00Z
an instant, not null
DateTimeException
if the instant exceeds the maximum or minimum 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);
the number of seconds from 1970-01-01T00:00:00Z
the nanosecond adjustment to the number of seconds, positive or negative
an instant, not null
ArithmeticException
if numeric overflow occurs
DateTimeException
if the instant exceeds the maximum or minimum 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.
the number of seconds from 1970-01-01T00:00:00Z
an instant, not null
DateTimeException
if the instant exceeds the maximum or minimum instant
Obtains an instance of Instant
from a text string such as
2007-12-03T10:15:30.000Z
.
Obtains an instance of Instant
from a text string such as
2007-12-03T10:15:30.000Z
.
The string must represent a valid instant in UTC and is parsed using
DateTimeFormatter#ISO_INSTANT
.
the text to parse, not null
the parsed instant, not null
DateTimeParseException
if the text cannot be parsed