133 /**
134 * The singleton instance for the 'Meiji' era (1868-01-01 - 1912-07-29)
135 * which has the value -1.
136 */
137 public static final JapaneseEra MEIJI = new JapaneseEra(-1, LocalDate.of(1868, 1, 1));
138 /**
139 * The singleton instance for the 'Taisho' era (1912-07-30 - 1926-12-24)
140 * which has the value 0.
141 */
142 public static final JapaneseEra TAISHO = new JapaneseEra(0, LocalDate.of(1912, 7, 30));
143 /**
144 * The singleton instance for the 'Showa' era (1926-12-25 - 1989-01-07)
145 * which has the value 1.
146 */
147 public static final JapaneseEra SHOWA = new JapaneseEra(1, LocalDate.of(1926, 12, 25));
148 /**
149 * The singleton instance for the 'Heisei' era (1989-01-08 - 2019-04-30)
150 * which has the value 2.
151 */
152 public static final JapaneseEra HEISEI = new JapaneseEra(2, LocalDate.of(1989, 1, 8));
153
154 // The number of predefined JapaneseEra constants.
155 // There may be a supplemental era defined by the property.
156 private static final int N_ERA_CONSTANTS = HEISEI.getValue() + ERA_OFFSET;
157
158 /**
159 * Serialization version.
160 */
161 private static final long serialVersionUID = 1466499369062886794L;
162
163 // array for the singleton JapaneseEra instances
164 private static final JapaneseEra[] KNOWN_ERAS;
165
166 static {
167 ERA_CONFIG = JapaneseChronology.JCAL.getEras();
168
169 KNOWN_ERAS = new JapaneseEra[ERA_CONFIG.length];
170 KNOWN_ERAS[0] = MEIJI;
171 KNOWN_ERAS[1] = TAISHO;
172 KNOWN_ERAS[2] = SHOWA;
173 KNOWN_ERAS[3] = HEISEI;
174 for (int i = N_ERA_CONSTANTS; i < ERA_CONFIG.length; i++) {
175 CalendarDate date = ERA_CONFIG[i].getSinceDate();
176 LocalDate isoDate = LocalDate.of(date.getYear(), date.getMonth(), date.getDayOfMonth());
177 KNOWN_ERAS[i] = new JapaneseEra(i - ERA_OFFSET + 1, isoDate);
178 }
179 };
180
181 /**
182 * The era value.
183 * @serial
184 */
185 private final transient int eraValue;
186
187 // the first day of the era
188 private final transient LocalDate since;
189
190 /**
191 * Creates an instance.
192 *
193 * @param eraValue the era value, validated
|
133 /**
134 * The singleton instance for the 'Meiji' era (1868-01-01 - 1912-07-29)
135 * which has the value -1.
136 */
137 public static final JapaneseEra MEIJI = new JapaneseEra(-1, LocalDate.of(1868, 1, 1));
138 /**
139 * The singleton instance for the 'Taisho' era (1912-07-30 - 1926-12-24)
140 * which has the value 0.
141 */
142 public static final JapaneseEra TAISHO = new JapaneseEra(0, LocalDate.of(1912, 7, 30));
143 /**
144 * The singleton instance for the 'Showa' era (1926-12-25 - 1989-01-07)
145 * which has the value 1.
146 */
147 public static final JapaneseEra SHOWA = new JapaneseEra(1, LocalDate.of(1926, 12, 25));
148 /**
149 * The singleton instance for the 'Heisei' era (1989-01-08 - 2019-04-30)
150 * which has the value 2.
151 */
152 public static final JapaneseEra HEISEI = new JapaneseEra(2, LocalDate.of(1989, 1, 8));
153 /**
154 * The singleton instance for the 'NewEra' era (2019-05-01 - current)
155 * which has the value 3.
156 */
157 private static final JapaneseEra NEWERA = new JapaneseEra(3, LocalDate.of(2019, 5, 1));
158
159 // The number of predefined JapaneseEra constants.
160 // There may be a supplemental era defined by the property.
161 private static final int N_ERA_CONSTANTS = NEWERA.getValue() + ERA_OFFSET;
162
163 /**
164 * Serialization version.
165 */
166 private static final long serialVersionUID = 1466499369062886794L;
167
168 // array for the singleton JapaneseEra instances
169 private static final JapaneseEra[] KNOWN_ERAS;
170
171 static {
172 ERA_CONFIG = JapaneseChronology.JCAL.getEras();
173
174 KNOWN_ERAS = new JapaneseEra[ERA_CONFIG.length];
175 KNOWN_ERAS[0] = MEIJI;
176 KNOWN_ERAS[1] = TAISHO;
177 KNOWN_ERAS[2] = SHOWA;
178 KNOWN_ERAS[3] = HEISEI;
179 KNOWN_ERAS[4] = NEWERA;
180 for (int i = N_ERA_CONSTANTS; i < ERA_CONFIG.length; i++) {
181 CalendarDate date = ERA_CONFIG[i].getSinceDate();
182 LocalDate isoDate = LocalDate.of(date.getYear(), date.getMonth(), date.getDayOfMonth());
183 KNOWN_ERAS[i] = new JapaneseEra(i - ERA_OFFSET + 1, isoDate);
184 }
185 };
186
187 /**
188 * The era value.
189 * @serial
190 */
191 private final transient int eraValue;
192
193 // the first day of the era
194 private final transient LocalDate since;
195
196 /**
197 * Creates an instance.
198 *
199 * @param eraValue the era value, validated
|