112 * such as {@code 2007-12-03}.
113 * <p>
114 * {@code LocalDate} is an immutable date-time object that represents a date,
115 * often viewed as year-month-day. Other date fields, such as day-of-year,
116 * day-of-week and week-of-year, can also be accessed.
117 * For example, the value "2nd October 2007" can be stored in a {@code LocalDate}.
118 * <p>
119 * This class does not store or represent a time or time-zone.
120 * Instead, it is a description of the date, as used for birthdays.
121 * It cannot represent an instant on the time-line without additional information
122 * such as an offset or time-zone.
123 * <p>
124 * The ISO-8601 calendar system is the modern civil calendar system used today
125 * in most of the world. It is equivalent to the proleptic Gregorian calendar
126 * system, in which today's rules for leap years are applied for all time.
127 * For most applications written today, the ISO-8601 rules are entirely suitable.
128 * However, any application that makes use of historical dates, and requires them
129 * to be accurate will find the ISO-8601 approach unsuitable.
130 * <p>
131 * This is a <a href="{@docRoot}/java.base/java/lang/doc-files/ValueBased.html">value-based</a>
132 * class; programmers should treat instances that are
133 * {@linkplain #equals(Object) equal} as interchangeable and should not
134 * use instances for synchronization, or unpredictable behavior may
135 * occur. For example, in a future release, synchronization may fail.
136 * The {@code equals} method should be used for comparisons.
137 *
138 * @implSpec
139 * This class is immutable and thread-safe.
140 *
141 * @since 1.8
142 */
143 @jdk.internal.ValueBased
144 public final class LocalDate
145 implements Temporal, TemporalAdjuster, ChronoLocalDate, Serializable {
146
147 /**
148 * For backward compatibility of the serialized {@code LocalDate.class} object,
149 * explicitly declare the types of the serialized fields as defined in Java SE 8.
150 * Instances of {@code LocalDate} are serialized using the dedicated
151 * serialized form by {@code writeReplace}.
152 * @serialField year int The year.
153 * @serialField month short The month-of-year.
154 * @serialField day short The day-of-month.
155 */
156 @Serial
157 private static final ObjectStreamField[] serialPersistentFields = {
158 new ObjectStreamField("year", int.class),
159 new ObjectStreamField("month", short.class),
160 new ObjectStreamField("day", short.class)
161 };
162
163 /**
|
112 * such as {@code 2007-12-03}.
113 * <p>
114 * {@code LocalDate} is an immutable date-time object that represents a date,
115 * often viewed as year-month-day. Other date fields, such as day-of-year,
116 * day-of-week and week-of-year, can also be accessed.
117 * For example, the value "2nd October 2007" can be stored in a {@code LocalDate}.
118 * <p>
119 * This class does not store or represent a time or time-zone.
120 * Instead, it is a description of the date, as used for birthdays.
121 * It cannot represent an instant on the time-line without additional information
122 * such as an offset or time-zone.
123 * <p>
124 * The ISO-8601 calendar system is the modern civil calendar system used today
125 * in most of the world. It is equivalent to the proleptic Gregorian calendar
126 * system, in which today's rules for leap years are applied for all time.
127 * For most applications written today, the ISO-8601 rules are entirely suitable.
128 * However, any application that makes use of historical dates, and requires them
129 * to be accurate will find the ISO-8601 approach unsuitable.
130 * <p>
131 * This is a <a href="{@docRoot}/java.base/java/lang/doc-files/ValueBased.html">value-based</a>
132 * class; programmers should treat instances that are {@linkplain #equals(Object) equal}
133 * as interchangeable and should not use instances for synchronization, mutexes, or
134 * with {@linkplain java.lang.ref.Reference object references}.
135 *
136 * <div class="preview-block">
137 * <div class="preview-comment">
138 * When preview features are enabled, {@code LocalDate} is a {@linkplain Class#isValue value class}.
139 * Use of value class instances for synchronization, mutexes, or with
140 * {@linkplain java.lang.ref.Reference object references} result in
141 * {@link IdentityException}.
142 * </div>
143 * </div>
144 *
145 * @implSpec
146 * This class is immutable and thread-safe.
147 *
148 * @since 1.8
149 */
150 @jdk.internal.ValueBased
151 @jdk.internal.MigratedValueClass
152 public final class LocalDate
153 implements Temporal, TemporalAdjuster, ChronoLocalDate, Serializable {
154
155 /**
156 * For backward compatibility of the serialized {@code LocalDate.class} object,
157 * explicitly declare the types of the serialized fields as defined in Java SE 8.
158 * Instances of {@code LocalDate} are serialized using the dedicated
159 * serialized form by {@code writeReplace}.
160 * @serialField year int The year.
161 * @serialField month short The month-of-year.
162 * @serialField day short The day-of-month.
163 */
164 @Serial
165 private static final ObjectStreamField[] serialPersistentFields = {
166 new ObjectStreamField("year", int.class),
167 new ObjectStreamField("month", short.class),
168 new ObjectStreamField("day", short.class)
169 };
170
171 /**
|