< prev index next >

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

Print this page

  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 import jdk.internal.util.DateTimeHelper;
  96 
  97 /**
  98  * A time with an offset from UTC/Greenwich in the ISO-8601 calendar system,
  99  * such as {@code 10:15:30+01:00}.
 100  * <p>
 101  * {@code OffsetTime} is an immutable date-time object that represents a time, often
 102  * viewed as hour-minute-second-offset.
 103  * This class stores all time fields, to a precision of nanoseconds,
 104  * as well as a zone offset.
 105  * For example, the value "13:45:30.123456789+02:00" can be stored
 106  * in an {@code OffsetTime}.
 107  * <p>
 108  * This is a <a href="{@docRoot}/java.base/java/lang/doc-files/ValueBased.html">value-based</a>
 109  * class; programmers should treat instances that are
 110  * {@linkplain #equals(Object) equal} as interchangeable and should not
 111  * use instances for synchronization, or unpredictable behavior may
 112  * occur. For example, in a future release, synchronization may fail.
 113  * The {@code equals} method should be used for comparisons.







 114  *
 115  * @implSpec
 116  * This class is immutable and thread-safe.
 117  *
 118  * @since 1.8
 119  */
 120 @jdk.internal.ValueBased

 121 public final class OffsetTime
 122         implements Temporal, TemporalAdjuster, Comparable<OffsetTime>, Serializable {
 123 
 124     /**
 125      * The minimum supported {@code OffsetTime}, '00:00:00+18:00'.
 126      * This is the time of midnight at the start of the day in the maximum offset
 127      * (larger offsets are earlier on the time-line).
 128      * This combines {@link LocalTime#MIN} and {@link ZoneOffset#MAX}.
 129      * This could be used by an application as a "far past" date.
 130      */
 131     public static final OffsetTime MIN = LocalTime.MIN.atOffset(ZoneOffset.MAX);
 132     /**
 133      * The maximum supported {@code OffsetTime}, '23:59:59.999999999-18:00'.
 134      * This is the time just before midnight at the end of the day in the minimum offset
 135      * (larger negative offsets are later on the time-line).
 136      * This combines {@link LocalTime#MAX} and {@link ZoneOffset#MIN}.
 137      * This could be used by an application as a "far future" date.
 138      */
 139     public static final OffsetTime MAX = LocalTime.MAX.atOffset(ZoneOffset.MIN);
 140 

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