< prev index next >

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

Print this page

 106  * often viewed as year-month-day-hour-minute-second. Other date and time fields,
 107  * such as day-of-year, day-of-week and week-of-year, can also be accessed.
 108  * Time is represented to nanosecond precision.
 109  * For example, the value "2nd October 2007 at 13:45.30.123456789" can be
 110  * stored in a {@code LocalDateTime}.
 111  * <p>
 112  * This class does not store or represent a time-zone.
 113  * Instead, it is a description of the date, as used for birthdays, combined with
 114  * the local time as seen on a wall clock.
 115  * It cannot represent an instant on the time-line without additional information
 116  * such as an offset or time-zone.
 117  * <p>
 118  * The ISO-8601 calendar system is the modern civil calendar system used today
 119  * in most of the world. It is equivalent to the proleptic Gregorian calendar
 120  * system, in which today's rules for leap years are applied for all time.
 121  * For most applications written today, the ISO-8601 rules are entirely suitable.
 122  * However, any application that makes use of historical dates, and requires them
 123  * to be accurate will find the ISO-8601 approach unsuitable.
 124  * <p>
 125  * This is a <a href="{@docRoot}/java.base/java/lang/doc-files/ValueBased.html">value-based</a>
 126  * class; programmers should treat instances that are
 127  * {@linkplain #equals(Object) equal} as interchangeable and should not
 128  * use instances for synchronization, or unpredictable behavior may
 129  * occur. For example, in a future release, synchronization may fail.
 130  * The {@code equals} method should be used for comparisons.







 131  *
 132  * @implSpec
 133  * This class is immutable and thread-safe.
 134  *
 135  * @since 1.8
 136  */
 137 @jdk.internal.ValueBased

 138 public final class LocalDateTime
 139         implements Temporal, TemporalAdjuster, ChronoLocalDateTime<LocalDate>, Serializable {
 140 
 141     /**
 142      * The minimum supported {@code LocalDateTime}, '-999999999-01-01T00:00:00'.
 143      * This is the local date-time of midnight at the start of the minimum date.
 144      * This combines {@link LocalDate#MIN} and {@link LocalTime#MIN}.
 145      * This could be used by an application as a "far past" date-time.
 146      */
 147     public static final LocalDateTime MIN = LocalDateTime.of(LocalDate.MIN, LocalTime.MIN);
 148     /**
 149      * The maximum supported {@code LocalDateTime}, '+999999999-12-31T23:59:59.999999999'.
 150      * This is the local date-time just before midnight at the end of the maximum date.
 151      * This combines {@link LocalDate#MAX} and {@link LocalTime#MAX}.
 152      * This could be used by an application as a "far future" date-time.
 153      */
 154     public static final LocalDateTime MAX = LocalDateTime.of(LocalDate.MAX, LocalTime.MAX);
 155 
 156     /**
 157      * Serialization version.

 106  * often viewed as year-month-day-hour-minute-second. Other date and time fields,
 107  * such as day-of-year, day-of-week and week-of-year, can also be accessed.
 108  * Time is represented to nanosecond precision.
 109  * For example, the value "2nd October 2007 at 13:45.30.123456789" can be
 110  * stored in a {@code LocalDateTime}.
 111  * <p>
 112  * This class does not store or represent a time-zone.
 113  * Instead, it is a description of the date, as used for birthdays, combined with
 114  * the local time as seen on a wall clock.
 115  * It cannot represent an instant on the time-line without additional information
 116  * such as an offset or time-zone.
 117  * <p>
 118  * The ISO-8601 calendar system is the modern civil calendar system used today
 119  * in most of the world. It is equivalent to the proleptic Gregorian calendar
 120  * system, in which today's rules for leap years are applied for all time.
 121  * For most applications written today, the ISO-8601 rules are entirely suitable.
 122  * However, any application that makes use of historical dates, and requires them
 123  * to be accurate will find the ISO-8601 approach unsuitable.
 124  * <p>
 125  * This is a <a href="{@docRoot}/java.base/java/lang/doc-files/ValueBased.html">value-based</a>
 126  * class; programmers should treat instances that are {@linkplain #equals(Object) equal}
 127  * as interchangeable and should not use instances for synchronization, mutexes, or
 128  * with {@linkplain java.lang.ref.Reference object references}.
 129  *
 130  * <div class="preview-block">
 131  *      <div class="preview-comment">
 132  *          When preview features are enabled, {@code LocalDateTime} is a {@linkplain Class#isValue value class}.
 133  *          Use of value class instances for synchronization, mutexes, or with
 134  *          {@linkplain java.lang.ref.Reference object references} result in
 135  *          {@link IdentityException}.
 136  *      </div>
 137  * </div>
 138  *
 139  * @implSpec
 140  * This class is immutable and thread-safe.
 141  *
 142  * @since 1.8
 143  */
 144 @jdk.internal.ValueBased
 145 @jdk.internal.MigratedValueClass
 146 public final class LocalDateTime
 147         implements Temporal, TemporalAdjuster, ChronoLocalDateTime<LocalDate>, Serializable {
 148 
 149     /**
 150      * The minimum supported {@code LocalDateTime}, '-999999999-01-01T00:00:00'.
 151      * This is the local date-time of midnight at the start of the minimum date.
 152      * This combines {@link LocalDate#MIN} and {@link LocalTime#MIN}.
 153      * This could be used by an application as a "far past" date-time.
 154      */
 155     public static final LocalDateTime MIN = LocalDateTime.of(LocalDate.MIN, LocalTime.MIN);
 156     /**
 157      * The maximum supported {@code LocalDateTime}, '+999999999-12-31T23:59:59.999999999'.
 158      * This is the local date-time just before midnight at the end of the maximum date.
 159      * This combines {@link LocalDate#MAX} and {@link LocalTime#MAX}.
 160      * This could be used by an application as a "far future" date-time.
 161      */
 162     public static final LocalDateTime MAX = LocalDateTime.of(LocalDate.MAX, LocalTime.MAX);
 163 
 164     /**
 165      * Serialization version.
< prev index next >