87 import java.time.temporal.TemporalQueries;
88 import java.time.temporal.TemporalQuery;
89 import java.time.temporal.TemporalUnit;
90 import java.time.temporal.UnsupportedTemporalTypeException;
91 import java.time.temporal.ValueRange;
92 import java.time.zone.ZoneRules;
93 import java.util.Objects;
94
95 /**
96 * A time with an offset from UTC/Greenwich in the ISO-8601 calendar system,
97 * such as {@code 10:15:30+01:00}.
98 * <p>
99 * {@code OffsetTime} is an immutable date-time object that represents a time, often
100 * viewed as hour-minute-second-offset.
101 * This class stores all time fields, to a precision of nanoseconds,
102 * as well as a zone offset.
103 * For example, the value "13:45:30.123456789+02:00" can be stored
104 * in an {@code OffsetTime}.
105 * <p>
106 * This is a <a href="{@docRoot}/java.base/java/lang/doc-files/ValueBased.html">value-based</a>
107 * class; programmers should treat instances that are
108 * {@linkplain #equals(Object) equal} as interchangeable and should not
109 * use instances for synchronization, or unpredictable behavior may
110 * occur. For example, in a future release, synchronization may fail.
111 * The {@code equals} method should be used for comparisons.
112 *
113 * @implSpec
114 * This class is immutable and thread-safe.
115 *
116 * @since 1.8
117 */
118 @jdk.internal.ValueBased
119 public final class OffsetTime
120 implements Temporal, TemporalAdjuster, Comparable<OffsetTime>, Serializable {
121
122 /**
123 * The minimum supported {@code OffsetTime}, '00:00:00+18:00'.
124 * This is the time of midnight at the start of the day in the maximum offset
125 * (larger offsets are earlier on the time-line).
126 * This combines {@link LocalTime#MIN} and {@link ZoneOffset#MAX}.
127 * This could be used by an application as a "far past" date.
128 */
129 public static final OffsetTime MIN = LocalTime.MIN.atOffset(ZoneOffset.MAX);
130 /**
131 * The maximum supported {@code OffsetTime}, '23:59:59.999999999-18:00'.
132 * This is the time just before midnight at the end of the day in the minimum offset
133 * (larger negative offsets are later on the time-line).
134 * This combines {@link LocalTime#MAX} and {@link ZoneOffset#MIN}.
135 * This could be used by an application as a "far future" date.
136 */
137 public static final OffsetTime MAX = LocalTime.MAX.atOffset(ZoneOffset.MIN);
138
|
87 import java.time.temporal.TemporalQueries;
88 import java.time.temporal.TemporalQuery;
89 import java.time.temporal.TemporalUnit;
90 import java.time.temporal.UnsupportedTemporalTypeException;
91 import java.time.temporal.ValueRange;
92 import java.time.zone.ZoneRules;
93 import java.util.Objects;
94
95 /**
96 * A time with an offset from UTC/Greenwich in the ISO-8601 calendar system,
97 * such as {@code 10:15:30+01:00}.
98 * <p>
99 * {@code OffsetTime} is an immutable date-time object that represents a time, often
100 * viewed as hour-minute-second-offset.
101 * This class stores all time fields, to a precision of nanoseconds,
102 * as well as a zone offset.
103 * For example, the value "13:45:30.123456789+02:00" can be stored
104 * in an {@code OffsetTime}.
105 * <p>
106 * This is a <a href="{@docRoot}/java.base/java/lang/doc-files/ValueBased.html">value-based</a>
107 * class; programmers should treat instances that are {@linkplain #equals(Object) equal}
108 * as interchangeable and should not use instances for synchronization, mutexes, or
109 * with {@linkplain java.lang.ref.Reference object references}.
110 *
111 * <div class="preview-block">
112 * <div class="preview-comment">
113 * When preview features are enabled, {@code OffsetTime} is a {@linkplain Class#isValue value class}.
114 * Use of value class instances for synchronization, mutexes, or with
115 * {@linkplain java.lang.ref.Reference object references} result in
116 * {@link IdentityException}.
117 * </div>
118 * </div>
119 *
120 * @implSpec
121 * This class is immutable and thread-safe.
122 *
123 * @since 1.8
124 */
125 @jdk.internal.ValueBased
126 @jdk.internal.MigratedValueClass
127 public final class OffsetTime
128 implements Temporal, TemporalAdjuster, Comparable<OffsetTime>, Serializable {
129
130 /**
131 * The minimum supported {@code OffsetTime}, '00:00:00+18:00'.
132 * This is the time of midnight at the start of the day in the maximum offset
133 * (larger offsets are earlier on the time-line).
134 * This combines {@link LocalTime#MIN} and {@link ZoneOffset#MAX}.
135 * This could be used by an application as a "far past" date.
136 */
137 public static final OffsetTime MIN = LocalTime.MIN.atOffset(ZoneOffset.MAX);
138 /**
139 * The maximum supported {@code OffsetTime}, '23:59:59.999999999-18:00'.
140 * This is the time just before midnight at the end of the day in the minimum offset
141 * (larger negative offsets are later on the time-line).
142 * This combines {@link LocalTime#MAX} and {@link ZoneOffset#MIN}.
143 * This could be used by an application as a "far future" date.
144 */
145 public static final OffsetTime MAX = LocalTime.MAX.atOffset(ZoneOffset.MIN);
146
|