86 import sun.util.calendar.CalendarDate; |
86 import sun.util.calendar.CalendarDate; |
87 |
87 |
88 /** |
88 /** |
89 * An era in the Japanese Imperial calendar system. |
89 * An era in the Japanese Imperial calendar system. |
90 * <p> |
90 * <p> |
91 * This class defines the valid eras for the Japanese chronology. |
91 * The Japanese government defines the official name and start date of |
92 * Japan introduced the Gregorian calendar starting with Meiji 6. |
92 * each era. Eras are consecutive and their date ranges do not overlap, |
93 * Only Meiji and later eras are supported; |
93 * so the end date of one era is always the day before the start date |
94 * dates before Meiji 6, January 1 are not supported. |
94 * of the next era. |
95 * The number of the valid eras may increase, as new eras may be |
95 * <p> |
96 * defined by the Japanese government. Once an era is defined, |
96 * The Java SE Platform supports all eras defined by the Japanese government, |
97 * future versions of the platform may add a singleton instance |
97 * beginning with the Meiji era. Each era is identified in the Platform by an |
98 * for it. The defined era is expected to have a consecutive integer |
98 * integer value and a name. The {@link #of(int)} and {@link #valueOf(String)} |
99 * associated with it. |
99 * methods may be used to obtain a singleton instance of {@code JapaneseEra} |
|
100 * for each era. The {@link #values()} method returns the singleton instances |
|
101 * of all supported eras. |
|
102 * <p> |
|
103 * For convenience, this class declares a number of public static final fields |
|
104 * that refer to singleton instances returned by the {@link #values()} method. |
|
105 * |
|
106 * @apiNote |
|
107 * The fields declared in this class may evolve over time, in line with the |
|
108 * results of the {@link #values()} method. However, there is not necessarily |
|
109 * a 1:1 correspondence between the fields and the singleton instances. |
|
110 * |
|
111 * @apiNote |
|
112 * The Japanese government may announce a new era and define its start |
|
113 * date but not its official name. In this scenario, the singleton instance |
|
114 * that represents the new era may return a name that is not stable until |
|
115 * the official name is defined. Developers should exercise caution when |
|
116 * relying on the name returned by any singleton instance that does not |
|
117 * correspond to a public static final field. |
100 * |
118 * |
101 * @implSpec |
119 * @implSpec |
102 * This class is immutable and thread-safe. |
120 * This class is immutable and thread-safe. |
103 * |
121 * |
104 * @since 1.8 |
122 * @since 1.8 |
197 } |
215 } |
198 |
216 |
199 //----------------------------------------------------------------------- |
217 //----------------------------------------------------------------------- |
200 /** |
218 /** |
201 * Obtains an instance of {@code JapaneseEra} from an {@code int} value. |
219 * Obtains an instance of {@code JapaneseEra} from an {@code int} value. |
202 * <p> |
220 * <ul> |
203 * The {@link #SHOWA} era that contains 1970-01-01 (ISO calendar system) has the value 1. |
221 * <li>The value {@code 1} is associated with the 'Showa' era, because |
204 * Later era is numbered 2 ({@link #HEISEI}). Earlier eras are numbered 0 ({@link #TAISHO}), |
222 * it contains 1970-01-01 (ISO calendar system).</li> |
205 * -1 ({@link #MEIJI}), only Meiji and later eras are supported. |
223 * <li>The values {@code -1} and {@code 0} are associated with two earlier |
206 * <p> |
224 * eras, Meiji and Taisho, respectively.</li> |
207 * In addition to the known era singletons, values for additional |
225 * <li>A value greater than {@code 1} is associated with a later era, |
208 * eras may be defined. Those values are the {@link Era#getValue()} |
226 * beginning with Heisei ({@code 2}).</li> |
209 * of corresponding eras from the {@link #values()} method. |
227 * </ul> |
|
228 * <p> |
|
229 * Every instance of {@code JapaneseEra} that is returned from the {@link #values()} |
|
230 * method has an int value (available via {@link Era#getValue()} which is |
|
231 * accepted by this method. |
210 * |
232 * |
211 * @param japaneseEra the era to represent |
233 * @param japaneseEra the era to represent |
212 * @return the {@code JapaneseEra} singleton, not null |
234 * @return the {@code JapaneseEra} singleton, not null |
213 * @throws DateTimeException if the value is invalid |
235 * @throws DateTimeException if the value is invalid |
214 */ |
236 */ |