Instant (Java SE 26 & JDK 26)
- All Implemented Interfaces:
Serializable, Comparable<Instant>, Temporal, TemporalAccessor, TemporalAdjuster
-
Field Summary
Fields
Constant for the 1970-01-01T00:00:00Z epoch instant.
The maximum supported
Instant, '1000000000-12-31T23:59:59.999999999Z'.The minimum supported
Instant, '-1000000000-01-01T00:00Z'. -
Method Summary
Adjusts the specified temporal object to have this instant.
Combines this instant with an offset to create an
OffsetDateTime.Combines this instant with a time-zone to create a
ZonedDateTime.intCompares this instant to the specified instant.
booleanChecks if this instant is equal to the specified instant.
Obtains an instance of
Instantfrom a temporal object.intGets the value of the specified field from this instant as an
int.longGets the number of seconds from the Java epoch of 1970-01-01T00:00:00Z.
longGets the value of the specified field from this instant as a
long.intgetNano()Gets the number of nanoseconds, later along the time-line, from the start of the second.
inthashCode()Returns a hash code for this instant.
booleanChecks if this instant is after the specified instant.
booleanChecks if this instant is before the specified instant.
booleanChecks if the specified field is supported.
booleanChecks if the specified unit is supported.
Returns a copy of this instant with the specified amount subtracted.
Returns a copy of this instant with the specified amount subtracted.
minusMillis(long millisToSubtract) Returns a copy of this instant with the specified duration in milliseconds subtracted.
minusNanos(long nanosToSubtract) Returns a copy of this instant with the specified duration in nanoseconds subtracted.
minusSeconds(long secondsToSubtract) Returns a copy of this instant with the specified duration in seconds subtracted.
now()Obtains the current instant from the system clock.
Obtains the current instant from the specified clock.
ofEpochMilli(long epochMilli) Obtains an instance of
Instantusing milliseconds from the epoch of 1970-01-01T00:00:00Z.ofEpochSecond(long epochSecond) Obtains an instance of
Instantusing seconds from the epoch of 1970-01-01T00:00:00Z.ofEpochSecond(long epochSecond, long nanoAdjustment) Obtains an instance of
Instantusing seconds from the epoch of 1970-01-01T00:00:00Z and nanosecond fraction of second.Obtains an instance of
Instantfrom a text string such as2007-12-03T10:15:30.00Z.Returns a copy of this instant with the specified amount added.
Returns a copy of this instant with the specified amount added.
plusMillis(long millisToAdd) Returns a copy of this instant with the specified duration in milliseconds added.
plusNanos(long nanosToAdd) Returns a copy of this instant with the specified duration in nanoseconds added.
Returns a copy of this instant with the specified duration added, with saturated semantics.
plusSeconds(long secondsToAdd) Returns a copy of this instant with the specified duration in seconds added.
<R> RQueries this instant using the specified query.
Gets the range of valid values for the specified field.
longConverts this instant to the number of milliseconds from the epoch of 1970-01-01T00:00:00Z.
toString()A string representation of this instant using ISO-8601 representation.
Returns a copy of this
Instanttruncated to the specified unit.Calculates the
Durationuntil anotherInstant.longCalculates the amount of time until another instant in terms of the specified unit.
Returns an adjusted copy of this instant.
Returns a copy of this instant with the specified field set to a new value.
Methods declared in class Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitCreates and returns a copy of this object.
protected voidDeprecated, for removal: This API element is subject to removal in a future version.
Returns the runtime class of this
Object.final voidWakes up a single thread that is waiting on this object's monitor.
final voidWakes up all threads that are waiting on this object's monitor.
final voidCauses the current thread to wait until it is awakened, typically by being notified or interrupted.
final voidwait(long timeoutMillis) Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.
final voidwait(long timeoutMillis, int nanos) Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.
-
Field Details
-
EPOCH
-
MIN
-
MAX
-
-
Method Details
-
now
-
now
-
ofEpochSecond
-
ofEpochSecond
-
ofEpochMilli
-
from
-
parse
-
isSupported
-
isSupported
-
range
-
get
-
getLong
-
getEpochSecond
-
getNano
-
with
-
with
-
truncatedTo
-
plus
-
plusSaturating
-
plus
-
plusSeconds
-
plusMillis
-
plusNanos
-
minus
-
minus
-
minusSeconds
-
minusMillis
-
minusNanos
-
query
-
adjustInto
-
until
-
until
-
atOffset
-
atZone
-
toEpochMilli
-
compareTo
-
isAfter
-
isBefore
-
equals
-
hashCode
-
toString
-