src/java.base/share/classes/java/time/chrono/JapaneseEra.java
changeset 54359 3d8934bf505a
parent 53614 125012edb689
child 54360 6a4abdb6749c
equal deleted inserted replaced
54358:72b637d53318 54359:3d8934bf505a
   149      * The singleton instance for the 'Heisei' era (1989-01-08 - 2019-04-30)
   149      * The singleton instance for the 'Heisei' era (1989-01-08 - 2019-04-30)
   150      * which has the value 2.
   150      * which has the value 2.
   151      */
   151      */
   152     public static final JapaneseEra HEISEI = new JapaneseEra(2, LocalDate.of(1989, 1, 8));
   152     public static final JapaneseEra HEISEI = new JapaneseEra(2, LocalDate.of(1989, 1, 8));
   153     /**
   153     /**
   154      * The singleton instance for the 'NewEra' era (2019-05-01 - current)
   154      * The singleton instance for the 'Reiwa' era (2019-05-01 - )
   155      * which has the value 3.
   155      * which has the value 3.
   156      */
   156      */
   157     private static final JapaneseEra NEWERA = new JapaneseEra(3, LocalDate.of(2019, 5, 1));
   157     private static final JapaneseEra REIWA = new JapaneseEra(3, LocalDate.of(2019, 5, 1));
   158 
   158 
   159     // The number of predefined JapaneseEra constants.
   159     // The number of predefined JapaneseEra constants.
   160     // There may be a supplemental era defined by the property.
   160     // There may be a supplemental era defined by the property.
   161     private static final int N_ERA_CONSTANTS = NEWERA.getValue() + ERA_OFFSET;
   161     private static final int N_ERA_CONSTANTS = REIWA.getValue() + ERA_OFFSET;
   162 
   162 
   163     /**
   163     /**
   164      * Serialization version.
   164      * Serialization version.
   165      */
   165      */
   166     private static final long serialVersionUID = 1466499369062886794L;
   166     private static final long serialVersionUID = 1466499369062886794L;
   174         KNOWN_ERAS = new JapaneseEra[ERA_CONFIG.length];
   174         KNOWN_ERAS = new JapaneseEra[ERA_CONFIG.length];
   175         KNOWN_ERAS[0] = MEIJI;
   175         KNOWN_ERAS[0] = MEIJI;
   176         KNOWN_ERAS[1] = TAISHO;
   176         KNOWN_ERAS[1] = TAISHO;
   177         KNOWN_ERAS[2] = SHOWA;
   177         KNOWN_ERAS[2] = SHOWA;
   178         KNOWN_ERAS[3] = HEISEI;
   178         KNOWN_ERAS[3] = HEISEI;
   179         KNOWN_ERAS[4] = NEWERA;
   179         KNOWN_ERAS[4] = REIWA;
   180         for (int i = N_ERA_CONSTANTS; i < ERA_CONFIG.length; i++) {
   180         for (int i = N_ERA_CONSTANTS; i < ERA_CONFIG.length; i++) {
   181             CalendarDate date = ERA_CONFIG[i].getSinceDate();
   181             CalendarDate date = ERA_CONFIG[i].getSinceDate();
   182             LocalDate isoDate = LocalDate.of(date.getYear(), date.getMonth(), date.getDayOfMonth());
   182             LocalDate isoDate = LocalDate.of(date.getYear(), date.getMonth(), date.getDayOfMonth());
   183             KNOWN_ERAS[i] = new JapaneseEra(i - ERA_OFFSET + 1, isoDate);
   183             KNOWN_ERAS[i] = new JapaneseEra(i - ERA_OFFSET + 1, isoDate);
   184         }
   184         }