95 * A date in the Japanese Imperial calendar system.
96 * <p>
97 * This date operates using the {@linkplain JapaneseChronology Japanese Imperial calendar}.
98 * This calendar system is primarily used in Japan.
99 * <p>
100 * The Japanese Imperial calendar system is the same as the ISO calendar system
101 * apart from the era-based year numbering. The proleptic-year is defined to be
102 * equal to the ISO proleptic-year.
103 * <p>
104 * Japan introduced the Gregorian calendar starting with Meiji 6.
105 * Only Meiji and later eras are supported;
106 * dates before Meiji 6, January 1 are not supported.
107 * <p>
108 * For example, the Japanese year "Heisei 24" corresponds to ISO year "2012".<br>
109 * Calling {@code japaneseDate.get(YEAR_OF_ERA)} will return 24.<br>
110 * Calling {@code japaneseDate.get(YEAR)} will return 2012.<br>
111 * Calling {@code japaneseDate.get(ERA)} will return 2, corresponding to
112 * {@code JapaneseChronology.ERA_HEISEI}.<br>
113 * <p>
114 * This is a <a href="{@docRoot}/java.base/java/lang/doc-files/ValueBased.html">value-based</a>
115 * class; programmers should treat instances that are
116 * {@linkplain #equals(Object) equal} as interchangeable and should not
117 * use instances for synchronization, or unpredictable behavior may
118 * occur. For example, in a future release, synchronization may fail.
119 * The {@code equals} method should be used for comparisons.
120 *
121 * @implSpec
122 * This class is immutable and thread-safe.
123 *
124 * @since 1.8
125 */
126 @jdk.internal.ValueBased
127 public final class JapaneseDate
128 extends ChronoLocalDateImpl<JapaneseDate>
129 implements ChronoLocalDate, Serializable {
130
131 /**
132 * Serialization version.
133 */
134 @java.io.Serial
135 private static final long serialVersionUID = -305327627230580483L;
136
137 /**
138 * The underlying ISO local date.
139 */
140 private final transient LocalDate isoDate;
141 /**
142 * The JapaneseEra of this date.
143 */
144 private final transient JapaneseEra era;
145 /**
146 * The Japanese imperial calendar year of this date.
|
95 * A date in the Japanese Imperial calendar system.
96 * <p>
97 * This date operates using the {@linkplain JapaneseChronology Japanese Imperial calendar}.
98 * This calendar system is primarily used in Japan.
99 * <p>
100 * The Japanese Imperial calendar system is the same as the ISO calendar system
101 * apart from the era-based year numbering. The proleptic-year is defined to be
102 * equal to the ISO proleptic-year.
103 * <p>
104 * Japan introduced the Gregorian calendar starting with Meiji 6.
105 * Only Meiji and later eras are supported;
106 * dates before Meiji 6, January 1 are not supported.
107 * <p>
108 * For example, the Japanese year "Heisei 24" corresponds to ISO year "2012".<br>
109 * Calling {@code japaneseDate.get(YEAR_OF_ERA)} will return 24.<br>
110 * Calling {@code japaneseDate.get(YEAR)} will return 2012.<br>
111 * Calling {@code japaneseDate.get(ERA)} will return 2, corresponding to
112 * {@code JapaneseChronology.ERA_HEISEI}.<br>
113 * <p>
114 * This is a <a href="{@docRoot}/java.base/java/lang/doc-files/ValueBased.html">value-based</a>
115 * class; programmers should treat instances that are {@linkplain #equals(Object) equal}
116 * as interchangeable and should not use instances for synchronization, mutexes, or
117 * with {@linkplain java.lang.ref.Reference object references}.
118 *
119 * <div class="preview-block">
120 * <div class="preview-comment">
121 * When preview features are enabled, {@code JapaneseDate} is a {@linkplain Class#isValue value class}.
122 * Use of value class instances for synchronization, mutexes, or with
123 * {@linkplain java.lang.ref.Reference object references} result in
124 * {@link IdentityException}.
125 * </div>
126 * </div>
127 *
128 * @implSpec
129 * This class is immutable and thread-safe.
130 *
131 * @since 1.8
132 */
133 @jdk.internal.ValueBased
134 @jdk.internal.MigratedValueClass
135 public final class JapaneseDate
136 extends ChronoLocalDateImpl<JapaneseDate>
137 implements ChronoLocalDate, Serializable {
138
139 /**
140 * Serialization version.
141 */
142 @java.io.Serial
143 private static final long serialVersionUID = -305327627230580483L;
144
145 /**
146 * The underlying ISO local date.
147 */
148 private final transient LocalDate isoDate;
149 /**
150 * The JapaneseEra of this date.
151 */
152 private final transient JapaneseEra era;
153 /**
154 * The Japanese imperial calendar year of this date.
|