changeset 54360:6a4abdb6749c

8174268: Declare a public field in JapaneseEra for the era starting May 2019 Reviewed-by: rriggs, chegar
author naoto
date Mon, 01 Apr 2019 08:21:45 -0700
parents 3d8934bf505a
children 879051d3772a
files src/java.base/share/classes/java/time/chrono/JapaneseChronology.java src/java.base/share/classes/java/time/chrono/JapaneseEra.java src/java.base/share/classes/java/util/spi/CalendarNameProvider.java test/jdk/java/time/tck/java/time/chrono/TCKJapaneseChronology.java test/jdk/java/time/tck/java/time/chrono/TCKJapaneseEra.java test/jdk/java/time/test/java/time/chrono/TestEraDisplayName.java test/jdk/java/time/test/java/time/chrono/TestJapaneseChronology.java
diffstat 7 files changed, 37 insertions(+), 27 deletions(-) [+]
line wrap: on
line diff
--- a/src/java.base/share/classes/java/time/chrono/JapaneseChronology.java	Mon Apr 01 08:19:21 2019 -0700
+++ b/src/java.base/share/classes/java/time/chrono/JapaneseChronology.java	Mon Apr 01 08:21:45 2019 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -363,9 +363,8 @@
     /**
      * Returns the calendar system era object from the given numeric value.
      *
-     * See the description of each Era for the numeric values of:
-     * {@link JapaneseEra#HEISEI}, {@link JapaneseEra#SHOWA},{@link JapaneseEra#TAISHO},
-     * {@link JapaneseEra#MEIJI}), only Meiji and later eras are supported.
+     * The numeric values supported by this method are the same as the
+     * numeric values supported by {@link JapaneseEra#of(int)}.
      *
      * @param eraValue  the era value
      * @return the Japanese {@code Era} for the given numeric era value
--- a/src/java.base/share/classes/java/time/chrono/JapaneseEra.java	Mon Apr 01 08:19:21 2019 -0700
+++ b/src/java.base/share/classes/java/time/chrono/JapaneseEra.java	Mon Apr 01 08:21:45 2019 -0700
@@ -152,9 +152,10 @@
     public static final JapaneseEra HEISEI = new JapaneseEra(2, LocalDate.of(1989, 1, 8));
     /**
      * The singleton instance for the 'Reiwa' era (2019-05-01 - )
-     * which has the value 3.
+     * which has the value 3. The end date of this era is not specified, unless
+     * the Japanese Government defines it.
      */
-    private static final JapaneseEra REIWA = new JapaneseEra(3, LocalDate.of(2019, 5, 1));
+    public static final JapaneseEra REIWA = new JapaneseEra(3, LocalDate.of(2019, 5, 1));
 
     // The number of predefined JapaneseEra constants.
     // There may be a supplemental era defined by the property.
--- a/src/java.base/share/classes/java/util/spi/CalendarNameProvider.java	Mon Apr 01 08:19:21 2019 -0700
+++ b/src/java.base/share/classes/java/util/spi/CalendarNameProvider.java	Mon Apr 01 08:21:45 2019 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -114,8 +114,8 @@
  *     <td>B.E. (Buddhist Era)</td>
  *   </tr>
  *   <tr>
- *     <th scope="row" rowspan="6" style="font-weight:normal; text-align:left; vertical-align:top">{@code "japanese"}</th>
- *     <th scope="row" rowspan="5" style="font-weight:normal; text-align:left; vertical-align:top">{@link Calendar#ERA}</th>
+ *     <th scope="row" rowspan="7" style="font-weight:normal; text-align:left; vertical-align:top">{@code "japanese"}</th>
+ *     <th scope="row" rowspan="6" style="font-weight:normal; text-align:left; vertical-align:top">{@link Calendar#ERA}</th>
  *     <th scope="row" style="font-weight:normal">0</th>
  *     <td>Seireki (Before Meiji)</td>
  *   </tr>
@@ -133,7 +133,11 @@
  *   </tr>
  *   <tr>
  *     <th scope="row" style="font-weight:normal">4</th>
- *     <td >Heisei</td>
+ *     <td>Heisei</td>
+ *   </tr>
+ *   <tr>
+ *     <th scope="row" style="font-weight:normal">5</th>
+ *     <td>Reiwa</td>
  *   </tr>
  *   <tr>
  *     <th scope="row" style="font-weight:normal; text-align:left; vertical-align:top">{@link Calendar#YEAR}</th>
--- a/test/jdk/java/time/tck/java/time/chrono/TCKJapaneseChronology.java	Mon Apr 01 08:19:21 2019 -0700
+++ b/test/jdk/java/time/tck/java/time/chrono/TCKJapaneseChronology.java	Mon Apr 01 08:21:45 2019 -0700
@@ -176,7 +176,7 @@
     @DataProvider(name="createByEra")
     Object[][] data_createByEra() {
         return new Object[][] {
-                {JapaneseEra.of(3), 2020 - YDIFF_REIWA, 2, 29, 60, LocalDate.of(2020, 2, 29)},
+                {JapaneseEra.REIWA, 2020 - YDIFF_REIWA, 2, 29, 60, LocalDate.of(2020, 2, 29)},
                 {JapaneseEra.HEISEI, 1996 - YDIFF_HEISEI, 2, 29, 60, LocalDate.of(1996, 2, 29)},
                 {JapaneseEra.HEISEI, 2000 - YDIFF_HEISEI, 2, 29, 60, LocalDate.of(2000, 2, 29)},
                 {JapaneseEra.MEIJI, 1874 - YDIFF_MEIJI, 2, 28, 59, LocalDate.of(1874, 2, 28)},
@@ -369,8 +369,8 @@
     @DataProvider(name="prolepticYear")
     Object[][] data_prolepticYear() {
         return new Object[][] {
-                {3, JapaneseEra.of(3), 1, 1 + YDIFF_REIWA, false},
-                {3, JapaneseEra.of(3), 102, 102 + YDIFF_REIWA, true},
+                {3, JapaneseEra.REIWA, 1, 1 + YDIFF_REIWA, false},
+                {3, JapaneseEra.REIWA, 102, 102 + YDIFF_REIWA, true},
 
                 {2, JapaneseEra.HEISEI, 1, 1 + YDIFF_HEISEI, false},
                 {2, JapaneseEra.HEISEI, 4, 4 + YDIFF_HEISEI, true},
@@ -555,7 +555,7 @@
             { JapaneseEra.TAISHO, 0, "Taisho"},
             { JapaneseEra.SHOWA, 1, "Showa"},
             { JapaneseEra.HEISEI, 2, "Heisei"},
-            { JapaneseEra.of(3), 3, "Reiwa"},
+            { JapaneseEra.REIWA, 3, "Reiwa"},
         };
     }
 
--- a/test/jdk/java/time/tck/java/time/chrono/TCKJapaneseEra.java	Mon Apr 01 08:19:21 2019 -0700
+++ b/test/jdk/java/time/tck/java/time/chrono/TCKJapaneseEra.java	Mon Apr 01 08:21:45 2019 -0700
@@ -79,7 +79,7 @@
     @DataProvider(name = "JapaneseEras")
     Object[][] data_of_eras() {
         return new Object[][] {
-                    {JapaneseEra.of(3), "Reiwa", 3},
+                    {JapaneseEra.REIWA, "Reiwa", 3},
                     {JapaneseEra.HEISEI, "Heisei", 2},
                     {JapaneseEra.SHOWA, "Showa", 1},
                     {JapaneseEra.TAISHO, "Taisho", 0},
--- a/test/jdk/java/time/test/java/time/chrono/TestEraDisplayName.java	Mon Apr 01 08:19:21 2019 -0700
+++ b/test/jdk/java/time/test/java/time/chrono/TestEraDisplayName.java	Mon Apr 01 08:21:45 2019 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -69,26 +69,32 @@
             { JapaneseEra.TAISHO,   TextStyle.FULL,     Locale.US,      "Taisho" },
             { JapaneseEra.SHOWA,    TextStyle.FULL,     Locale.US,      "Showa" },
             { JapaneseEra.HEISEI,   TextStyle.FULL,     Locale.US,      "Heisei" },
+            { JapaneseEra.REIWA,    TextStyle.FULL,     Locale.US,      "Reiwa" },
             { JapaneseEra.MEIJI,    TextStyle.FULL,     Locale.JAPAN,   "\u660e\u6cbb" },
             { JapaneseEra.TAISHO,   TextStyle.FULL,     Locale.JAPAN,   "\u5927\u6b63" },
             { JapaneseEra.SHOWA,    TextStyle.FULL,     Locale.JAPAN,   "\u662d\u548c" },
             { JapaneseEra.HEISEI,   TextStyle.FULL,     Locale.JAPAN,   "\u5e73\u6210" },
+            { JapaneseEra.REIWA,    TextStyle.FULL,     Locale.JAPAN,   "\u4ee4\u548c" },
             { JapaneseEra.MEIJI,    TextStyle.SHORT,    Locale.US,      "Meiji" },
             { JapaneseEra.TAISHO,   TextStyle.SHORT,    Locale.US,      "Taisho" },
             { JapaneseEra.SHOWA,    TextStyle.SHORT,    Locale.US,      "Showa" },
             { JapaneseEra.HEISEI,   TextStyle.SHORT,    Locale.US,      "Heisei" },
+            { JapaneseEra.REIWA,    TextStyle.SHORT,    Locale.US,      "Reiwa" },
             { JapaneseEra.MEIJI,    TextStyle.SHORT,    Locale.JAPAN,   "\u660e\u6cbb" },
             { JapaneseEra.TAISHO,   TextStyle.SHORT,    Locale.JAPAN,   "\u5927\u6b63" },
             { JapaneseEra.SHOWA,    TextStyle.SHORT,    Locale.JAPAN,   "\u662d\u548c" },
             { JapaneseEra.HEISEI,   TextStyle.SHORT,    Locale.JAPAN,   "\u5e73\u6210" },
+            { JapaneseEra.REIWA,    TextStyle.SHORT,    Locale.JAPAN,   "\u4ee4\u548c" },
             { JapaneseEra.MEIJI,    TextStyle.NARROW,   Locale.US,      "M" },
             { JapaneseEra.TAISHO,   TextStyle.NARROW,   Locale.US,      "T" },
             { JapaneseEra.SHOWA,    TextStyle.NARROW,   Locale.US,      "S" },
             { JapaneseEra.HEISEI,   TextStyle.NARROW,   Locale.US,      "H" },
+            { JapaneseEra.REIWA,    TextStyle.NARROW,   Locale.US,      "R" },
             { JapaneseEra.MEIJI,    TextStyle.NARROW,   Locale.JAPAN,   "M" },
             { JapaneseEra.TAISHO,   TextStyle.NARROW,   Locale.JAPAN,   "T" },
             { JapaneseEra.SHOWA,    TextStyle.NARROW,   Locale.JAPAN,   "S" },
             { JapaneseEra.HEISEI,   TextStyle.NARROW,   Locale.JAPAN,   "H" },
+            { JapaneseEra.REIWA,    TextStyle.NARROW,   Locale.JAPAN,   "R" },
 
             // ThaiBuddhistEra
             { ThaiBuddhistEra.BEFORE_BE,    TextStyle.FULL, Locale.US,      "BC" },
--- a/test/jdk/java/time/test/java/time/chrono/TestJapaneseChronology.java	Mon Apr 01 08:19:21 2019 -0700
+++ b/test/jdk/java/time/test/java/time/chrono/TestJapaneseChronology.java	Mon Apr 01 08:21:45 2019 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2019, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -60,7 +60,7 @@
             { JapaneseEra.SHOWA,     64,  1,  7, 1989 },
             { JapaneseEra.HEISEI,     1,  1,  8, 1989 },
             { JapaneseEra.HEISEI,    31,  4, 30, 2019 },
-            { JapaneseEra.of(3),      1,  5,  1, 2019 },
+            { JapaneseEra.REIWA,      1,  5,  1, 2019 },
         };
     }
 
@@ -78,7 +78,7 @@
             { JapaneseEra.HEISEI,  1,    1,  1,  8 },
             { JapaneseEra.HEISEI,  2,    8,  1,  8 },
             { JapaneseEra.HEISEI, 31,  120,  4, 30 },
-            { JapaneseEra.of(3),   1,    1,  5,  1 },
+            { JapaneseEra.REIWA,   1,    1,  5,  1 },
         };
     }
 
@@ -111,8 +111,8 @@
             { JapaneseEra.HEISEI,     1,  1,  7 },
             { JapaneseEra.HEISEI,     1,  2, 29 },
             { JapaneseEra.HEISEI,    31,  5,  1 },
-            { JapaneseEra.of(3),      1,  4, 30 },
-            { JapaneseEra.of(3), Year.MAX_VALUE,  12, 31 },
+            { JapaneseEra.REIWA,      1,  4, 30 },
+            { JapaneseEra.REIWA, Year.MAX_VALUE,  12, 31 },
         };
     }
 
@@ -132,9 +132,9 @@
             { JapaneseEra.HEISEI,    -1 },
             { JapaneseEra.HEISEI,     0 },
             { JapaneseEra.HEISEI,    32 },
-            { JapaneseEra.of(3),     -1 },
-            { JapaneseEra.of(3),      0 },
-            { JapaneseEra.of(3), Year.MAX_VALUE },
+            { JapaneseEra.REIWA,     -1 },
+            { JapaneseEra.REIWA,      0 },
+            { JapaneseEra.REIWA, Year.MAX_VALUE },
         };
     }
 
@@ -152,8 +152,8 @@
             { JapaneseEra.HEISEI,  1, 360 },
             { JapaneseEra.HEISEI,  2, 366 },
             { JapaneseEra.HEISEI, 31, 121 },
-            { JapaneseEra.of(3),   1, 246 },
-            { JapaneseEra.of(3),   2, 367 },
+            { JapaneseEra.REIWA,   1, 246 },
+            { JapaneseEra.REIWA,   2, 367 },
         };
     }
 
@@ -165,7 +165,7 @@
             { "Taisho", JapaneseEra.TAISHO,     null },
             { "Showa",  JapaneseEra.SHOWA,      null },
             { "Heisei", JapaneseEra.HEISEI,     null },
-            { "Reiwa", JapaneseEra.of(3),       null },
+            { "Reiwa", JapaneseEra.REIWA,       null },
             { "NewEra", null,                   IllegalArgumentException.class},
         };
     }