Instant
is an implementation of {@link ReadableInstant}. As with all instants, it represents an exact point on the time-line, but limited to the precision of milliseconds. An Instant
should be used to represent a point in time irrespective of any other factor, such as chronology or time zone.
Internally, the class holds one piece of data, the instant as milliseconds from the Java epoch of 1970-01-01T00:00:00Z.
For example, an Instant can be used to compare two DateTime
objects irrespective of chronology or time zone.
boolean sameInstant = dt1.toInstant().equals(dt2.toInstant());Note that the following code will also perform the same check:
boolean sameInstant = dt1.isEqual(dt2);
Instant is thread-safe and immutable. @author Stephen Colebourne @since 1.0
For the segment prior to 1972-11-03, extending back arbitrarily far, the consensus international time scale is defined to be UT1, applied proleptically, which is equivalent to the (mean) solar time on the prime meridian (Greenwich). In this segment, the Java Time-Scale is identical to the consensus international time scale. The exact boundary between the two segments is the instant where UT1 = UTC between 1972-11-03T00:00 and 1972-11-04T12:00.
Implementations of the Java time-scale using the JSR-310 API are not required to provide any clock that is sub-second accurate, or that progresses monotonically or smoothly. Implementations are therefore not required to actually perform the UTC-SLS slew or to otherwise be aware of leap seconds. JSR-310 does, however, require that implementations must document the approach they use when defining a clock representing the current instant. See {@link Clock} for details on the available clocks.
The Java time-scale is used for all date-time classes. This includes {@code Instant}, {@code LocalDate}, {@code LocalTime}, {@code OffsetDateTime}, {@code ZonedDateTime} and {@code Duration}.
This is a value-based class; use of identity-sensitive operations (including reference equality ( {@code ==}), identity hash code, or synchronization) on instances of {@code Instant} may have unpredictable results and should be avoided.The {@code equals} method should be used for comparisons. @implSpec This class is immutable and thread-safe. @since 1.8
The Time Framework for Java models time as a series of instantaneous events, known as instants, along a single time-line. This class represents one of those instants.
A physical instant is an instantaneous event. However, for practicality the API and this class uses a precision of nanoseconds.
A physical instant could be at any point on an infinite time-line. However, for practicality the API and this class limits the measurable time-line to the number of seconds that can be held in a {@code long}. This is greater than the current estimated age of the universe.
In order to represent the data a 96 bit number is required. To achieve this the data is stored as seconds, measured using a {@code long}, and nanoseconds, measured using an {@code int}. The nanosecond part will always be between 0 and 999,999,999 representing the nanosecond part of the second.
The seconds are measured from the standard Java epoch of 1970-01-01T00:00:00Z. Instants on the time-line after the epoch are positive, earlier are negative.
This class uses the {@link TimeScales#simplifiedUtc() simplified UTC} time scale.The scale keeps in step with true UTC by simply ignoring leap seconds. This scale has been chosen as the default because it is simple to understand and is what most users of the API expect. If the application needs an accurate time scale that is aware of leap seconds then {@link TimeScaleInstant} shouldbe used.
Instant is immutable and thread-safe. @author Michael Nascimento Santos @author Stephen Colebourne
Instant
is an implementation of {@link ReadableInstant}. As with all instants, it represents an exact point on the time-line, but limited to the precision of milliseconds. An Instant
should be used to represent a point in time irrespective of any other factor, such as chronology or time zone.
Internally, the class holds one piece of data, the instant as milliseconds from the Java epoch of 1970-01-01T00:00:00Z.
For example, an Instant can be used to compare two DateTime
objects irrespective of chronology or time zone.
boolean sameInstant = dt1.toInstant().equals(dt2.toInstant());Note that the following code will also perform the same check:
boolean sameInstant = dt1.isEqual(dt2);
Instant is thread-safe and immutable. @author Stephen Colebourne @since 1.0
Instant
is an implementation of {@link ReadableInstant}. As with all instants, it represents an exact point on the time-line, but limited to the precision of milliseconds. An Instant
should be used to represent a point in time irrespective of any other factor, such as chronology or time zone.
Internally, the class holds one piece of data, the instant as milliseconds from the Java epoch of 1970-01-01T00:00:00Z.
For example, an Instant can be used to compare two DateTime
objects irrespective of chronology or time zone.
boolean sameInstant = dt1.toInstant().equals(dt2.toInstant());Note that the following code will also perform the same check:
boolean sameInstant = dt1.isEqual(dt2);
Instant is thread-safe and immutable. @author Stephen Colebourne @since 1.0
One final problem is the definition of the agreed international civil time before the introduction of modern UTC in 1972. This includes the Java epoch of {@code 1970-01-01}. It is intended that instants before 1972 be interpreted based on the solar day divided into 86400 subdivisions.
The Java time-scale is used by all date-time classes. This includes {@code Instant}, {@code LocalDate}, {@code LocalTime}, {@code OffsetDateTime}, {@code ZonedDateTime} and {@code Duration}.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|