97 * A date-time with an offset from UTC/Greenwich in the ISO-8601 calendar system,
98 * such as {@code 2007-12-03T10:15:30+01:00}.
99 * <p>
100 * {@code OffsetDateTime} is an immutable representation of a date-time with an offset.
101 * This class stores all date and time fields, to a precision of nanoseconds,
102 * as well as the offset from UTC/Greenwich. For example, the value
103 * "2nd October 2007 at 13:45:30.123456789 +02:00" can be stored in an {@code OffsetDateTime}.
104 * <p>
105 * {@code OffsetDateTime}, {@link java.time.ZonedDateTime} and {@link java.time.Instant} all store an instant
106 * on the time-line to nanosecond precision.
107 * {@code Instant} is the simplest, simply representing the instant.
108 * {@code OffsetDateTime} adds to the instant the offset from UTC/Greenwich, which allows
109 * the local date-time to be obtained.
110 * {@code ZonedDateTime} adds full time-zone rules.
111 * <p>
112 * It is intended that {@code ZonedDateTime} or {@code Instant} is used to model data
113 * in simpler applications. This class may be used when modeling date-time concepts in
114 * more detail, or when communicating to a database or in a network protocol.
115 * <p>
116 * This is a <a href="{@docRoot}/java.base/java/lang/doc-files/ValueBased.html">value-based</a>
117 * class; programmers should treat instances that are
118 * {@linkplain #equals(Object) equal} as interchangeable and should not
119 * use instances for synchronization, or unpredictable behavior may
120 * occur. For example, in a future release, synchronization may fail.
121 * The {@code equals} method should be used for comparisons.
122 *
123 * @implSpec
124 * This class is immutable and thread-safe.
125 *
126 * @since 1.8
127 */
128 @jdk.internal.ValueBased
129 public final class OffsetDateTime
130 implements Temporal, TemporalAdjuster, Comparable<OffsetDateTime>, Serializable {
131
132 /**
133 * The minimum supported {@code OffsetDateTime}, '-999999999-01-01T00:00:00+18:00'.
134 * This is the local date-time of midnight at the start of the minimum date
135 * in the maximum offset (larger offsets are earlier on the time-line).
136 * This combines {@link LocalDateTime#MIN} and {@link ZoneOffset#MAX}.
137 * This could be used by an application as a "far past" date-time.
138 */
139 public static final OffsetDateTime MIN = LocalDateTime.MIN.atOffset(ZoneOffset.MAX);
140 /**
141 * The maximum supported {@code OffsetDateTime}, '+999999999-12-31T23:59:59.999999999-18:00'.
142 * This is the local date-time just before midnight at the end of the maximum date
143 * in the minimum offset (larger negative offsets are later on the time-line).
144 * This combines {@link LocalDateTime#MAX} and {@link ZoneOffset#MIN}.
145 * This could be used by an application as a "far future" date-time.
146 */
147 public static final OffsetDateTime MAX = LocalDateTime.MAX.atOffset(ZoneOffset.MIN);
148
|
97 * A date-time with an offset from UTC/Greenwich in the ISO-8601 calendar system,
98 * such as {@code 2007-12-03T10:15:30+01:00}.
99 * <p>
100 * {@code OffsetDateTime} is an immutable representation of a date-time with an offset.
101 * This class stores all date and time fields, to a precision of nanoseconds,
102 * as well as the offset from UTC/Greenwich. For example, the value
103 * "2nd October 2007 at 13:45:30.123456789 +02:00" can be stored in an {@code OffsetDateTime}.
104 * <p>
105 * {@code OffsetDateTime}, {@link java.time.ZonedDateTime} and {@link java.time.Instant} all store an instant
106 * on the time-line to nanosecond precision.
107 * {@code Instant} is the simplest, simply representing the instant.
108 * {@code OffsetDateTime} adds to the instant the offset from UTC/Greenwich, which allows
109 * the local date-time to be obtained.
110 * {@code ZonedDateTime} adds full time-zone rules.
111 * <p>
112 * It is intended that {@code ZonedDateTime} or {@code Instant} is used to model data
113 * in simpler applications. This class may be used when modeling date-time concepts in
114 * more detail, or when communicating to a database or in a network protocol.
115 * <p>
116 * This is a <a href="{@docRoot}/java.base/java/lang/doc-files/ValueBased.html">value-based</a>
117 * class; programmers should treat instances that are {@linkplain #equals(Object) equal}
118 * as interchangeable and should not use instances for synchronization, mutexes, or
119 * with {@linkplain java.lang.ref.Reference object references}.
120 *
121 * <div class="preview-block">
122 * <div class="preview-comment">
123 * When preview features are enabled, {@code OffsetDateTime} is a {@linkplain Class#isValue value class}.
124 * Use of value class instances for synchronization, mutexes, or with
125 * {@linkplain java.lang.ref.Reference object references} result in
126 * {@link IdentityException}.
127 * </div>
128 * </div>
129 *
130 * @implSpec
131 * This class is immutable and thread-safe.
132 *
133 * @since 1.8
134 */
135 @jdk.internal.ValueBased
136 @jdk.internal.MigratedValueClass
137 public final class OffsetDateTime
138 implements Temporal, TemporalAdjuster, Comparable<OffsetDateTime>, Serializable {
139
140 /**
141 * The minimum supported {@code OffsetDateTime}, '-999999999-01-01T00:00:00+18:00'.
142 * This is the local date-time of midnight at the start of the minimum date
143 * in the maximum offset (larger offsets are earlier on the time-line).
144 * This combines {@link LocalDateTime#MIN} and {@link ZoneOffset#MAX}.
145 * This could be used by an application as a "far past" date-time.
146 */
147 public static final OffsetDateTime MIN = LocalDateTime.MIN.atOffset(ZoneOffset.MAX);
148 /**
149 * The maximum supported {@code OffsetDateTime}, '+999999999-12-31T23:59:59.999999999-18:00'.
150 * This is the local date-time just before midnight at the end of the maximum date
151 * in the minimum offset (larger negative offsets are later on the time-line).
152 * This combines {@link LocalDateTime#MAX} and {@link ZoneOffset#MIN}.
153 * This could be used by an application as a "far future" date-time.
154 */
155 public static final OffsetDateTime MAX = LocalDateTime.MAX.atOffset(ZoneOffset.MIN);
156
|