< prev index next >

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

Print this page

  99  * A date-time with an offset from UTC/Greenwich in the ISO-8601 calendar system,
 100  * such as {@code 2007-12-03T10:15:30+01:00}.
 101  * <p>
 102  * {@code OffsetDateTime} is an immutable representation of a date-time with an offset.
 103  * This class stores all date and time fields, to a precision of nanoseconds,
 104  * as well as the offset from UTC/Greenwich. For example, the value
 105  * "2nd October 2007 at 13:45:30.123456789 +02:00" can be stored in an {@code OffsetDateTime}.
 106  * <p>
 107  * {@code OffsetDateTime}, {@link java.time.ZonedDateTime} and {@link java.time.Instant} all store an instant
 108  * on the time-line to nanosecond precision.
 109  * {@code Instant} is the simplest, simply representing the instant.
 110  * {@code OffsetDateTime} adds to the instant the offset from UTC/Greenwich, which allows
 111  * the local date-time to be obtained.
 112  * {@code ZonedDateTime} adds full time-zone rules.
 113  * <p>
 114  * It is intended that {@code ZonedDateTime} or {@code Instant} is used to model data
 115  * in simpler applications. This class may be used when modeling date-time concepts in
 116  * more detail, or when communicating to a database or in a network protocol.
 117  * <p>
 118  * This is a <a href="{@docRoot}/java.base/java/lang/doc-files/ValueBased.html">value-based</a>
 119  * class; programmers should treat instances that are
 120  * {@linkplain #equals(Object) equal} as interchangeable and should not
 121  * use instances for synchronization, or unpredictable behavior may
 122  * occur. For example, in a future release, synchronization may fail.
 123  * The {@code equals} method should be used for comparisons.







 124  *
 125  * @implSpec
 126  * This class is immutable and thread-safe.
 127  *
 128  * @since 1.8
 129  */
 130 @jdk.internal.ValueBased

 131 public final class OffsetDateTime
 132         implements Temporal, TemporalAdjuster, Comparable<OffsetDateTime>, Serializable {
 133 
 134     /**
 135      * The minimum supported {@code OffsetDateTime}, '-999999999-01-01T00:00:00+18:00'.
 136      * This is the local date-time of midnight at the start of the minimum date
 137      * in the maximum offset (larger offsets are earlier on the time-line).
 138      * This combines {@link LocalDateTime#MIN} and {@link ZoneOffset#MAX}.
 139      * This could be used by an application as a "far past" date-time.
 140      */
 141     public static final OffsetDateTime MIN = LocalDateTime.MIN.atOffset(ZoneOffset.MAX);
 142     /**
 143      * The maximum supported {@code OffsetDateTime}, '+999999999-12-31T23:59:59.999999999-18:00'.
 144      * This is the local date-time just before midnight at the end of the maximum date
 145      * in the minimum offset (larger negative offsets are later on the time-line).
 146      * This combines {@link LocalDateTime#MAX} and {@link ZoneOffset#MIN}.
 147      * This could be used by an application as a "far future" date-time.
 148      */
 149     public static final OffsetDateTime MAX = LocalDateTime.MAX.atOffset(ZoneOffset.MIN);
 150 

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