< prev index next >

src/java.base/share/classes/java/time/ZonedDateTime.java

Print this page

 145  * <p>
 146  * This is a <a href="{@docRoot}/java.base/java/lang/doc-files/ValueBased.html">value-based</a>
 147  * class; programmers should treat instances that are
 148  * {@linkplain #equals(Object) equal} as interchangeable and should not
 149  * use instances for synchronization, or unpredictable behavior may
 150  * occur. For example, in a future release, synchronization may fail.
 151  * The {@code equals} method should be used for comparisons.
 152  *
 153  * @implSpec
 154  * A {@code ZonedDateTime} holds state equivalent to three separate objects,
 155  * a {@code LocalDateTime}, a {@code ZoneId} and the resolved {@code ZoneOffset}.
 156  * The offset and local date-time are used to define an instant when necessary.
 157  * The zone ID is used to obtain the rules for how and when the offset changes.
 158  * The offset cannot be freely set, as the zone controls which offsets are valid.
 159  * <p>
 160  * This class is immutable and thread-safe.
 161  *
 162  * @since 1.8
 163  */
 164 @jdk.internal.ValueBased

 165 public final class ZonedDateTime
 166         implements Temporal, ChronoZonedDateTime<LocalDate>, Serializable {
 167 
 168     /**
 169      * Serialization version.
 170      */
 171     @java.io.Serial
 172     private static final long serialVersionUID = -6260982410461394882L;
 173 
 174     /**
 175      * The local date-time.
 176      */
 177     private final LocalDateTime dateTime;
 178     /**
 179      * The offset from UTC/Greenwich.
 180      */
 181     private final ZoneOffset offset;
 182     /**
 183      * The time-zone.
 184      */

 145  * <p>
 146  * This is a <a href="{@docRoot}/java.base/java/lang/doc-files/ValueBased.html">value-based</a>
 147  * class; programmers should treat instances that are
 148  * {@linkplain #equals(Object) equal} as interchangeable and should not
 149  * use instances for synchronization, or unpredictable behavior may
 150  * occur. For example, in a future release, synchronization may fail.
 151  * The {@code equals} method should be used for comparisons.
 152  *
 153  * @implSpec
 154  * A {@code ZonedDateTime} holds state equivalent to three separate objects,
 155  * a {@code LocalDateTime}, a {@code ZoneId} and the resolved {@code ZoneOffset}.
 156  * The offset and local date-time are used to define an instant when necessary.
 157  * The zone ID is used to obtain the rules for how and when the offset changes.
 158  * The offset cannot be freely set, as the zone controls which offsets are valid.
 159  * <p>
 160  * This class is immutable and thread-safe.
 161  *
 162  * @since 1.8
 163  */
 164 @jdk.internal.ValueBased
 165 @jdk.internal.MigratedValueClass
 166 public final class ZonedDateTime
 167         implements Temporal, ChronoZonedDateTime<LocalDate>, Serializable {
 168 
 169     /**
 170      * Serialization version.
 171      */
 172     @java.io.Serial
 173     private static final long serialVersionUID = -6260982410461394882L;
 174 
 175     /**
 176      * The local date-time.
 177      */
 178     private final LocalDateTime dateTime;
 179     /**
 180      * The offset from UTC/Greenwich.
 181      */
 182     private final ZoneOffset offset;
 183     /**
 184      * The time-zone.
 185      */
< prev index next >