changeset 8825:2acfc339e1bf

8205432: Replace the placeholder Japanese era name Summary: Also brings in some cleanups from JDK-8048123 Reviewed-by: rriggs, chegar, phh, clanger, aph
author andrew
date Mon, 15 Apr 2019 04:35:08 +0100
parents 25f38e64271f
children 6e87915b6725
files src/share/classes/java/util/JapaneseImperialCalendar.java src/share/classes/sun/text/resources/FormatData.java src/share/classes/sun/text/resources/FormatData_ja.java src/share/classes/sun/util/calendar/Era.java src/share/lib/calendars.properties test/java/text/Format/DateFormat/WeekDateTest.java test/java/util/Calendar/CalendarTestScripts/CalendarAdapter.java test/java/util/Calendar/CalendarTestScripts/Symbol.java test/java/util/Calendar/CalendarTestScripts/japanese/japanese.cts test/java/util/Calendar/CalendarTestScripts/japanese/japanese_add.cts test/java/util/Calendar/CalendarTestScripts/japanese/japanese_minmax.cts test/java/util/Calendar/CalendarTestScripts/japanese/japanese_roll.cts test/java/util/Calendar/JapaneseEraNameTest.java test/java/util/Calendar/JapaneseLenientEraTest.java
diffstat 14 files changed, 76 insertions(+), 77 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/java/util/JapaneseImperialCalendar.java	Mon Apr 15 03:00:17 2019 +0100
+++ b/src/share/classes/java/util/JapaneseImperialCalendar.java	Mon Apr 15 04:35:08 2019 +0100
@@ -38,21 +38,21 @@
 import sun.util.resources.LocaleData;
 
 /**
- * <code>JapaneseImperialCalendar</code> implements a Japanese
+ * {@code JapaneseImperialCalendar} implements a Japanese
  * calendar system in which the imperial era-based year numbering is
  * supported from the Meiji era. The following are the eras supported
  * by this calendar system.
- * <pre><tt>
+ * <pre>{@code
  * ERA value   Era name    Since (in Gregorian)
  * ------------------------------------------------------
  *     0       N/A         N/A
- *     1       Meiji       1868-01-01 midnight local time
- *     2       Taisho      1912-07-30 midnight local time
- *     3       Showa       1926-12-25 midnight local time
- *     4       Heisei      1989-01-08 midnight local time
- *     5       NewEra      2019-05-01 midnight local time
+ *     1       Meiji       1868-01-01T00:00:00 local time
+ *     2       Taisho      1912-07-30T00:00:00 local time
+ *     3       Showa       1926-12-25T00:00:00 local time
+ *     4       Heisei      1989-01-08T00:00:00 local time
+ *     5       Reiwa       2019-05-01T00:00:00 local time
  * ------------------------------------------------------
- * </tt></pre>
+ * }</pre>
  *
  * <p><code>ERA</code> value 0 specifies the years before Meiji and
  * the Gregorian year values are used. Unlike {@link
@@ -103,12 +103,11 @@
     public static final int HEISEI = 4;
 
     /**
-     * The ERA constant designating the NewEra era.
+     * The ERA constant designating the Reiwa era.
      */
-    private static final int NEWERA = 5;
+    private static final int REIWA = 5;
 
     private static final int EPOCH_OFFSET   = 719163; // Fixed date of January 1, 1970 (Gregorian)
-    private static final int EPOCH_YEAR     = 1970;
 
     // Useful millisecond constants.  Although ONE_DAY and ONE_WEEK can fit
     // into ints, they must be longs in order to prevent arithmetic overflow
@@ -327,6 +326,7 @@
      * <code>false</code> otherwise.
      * @see Calendar#compareTo(Calendar)
      */
+    @Override
     public boolean equals(Object obj) {
         return obj instanceof JapaneseImperialCalendar &&
             super.equals(obj);
@@ -336,6 +336,7 @@
      * Generates the hash code for this
      * <code>JapaneseImperialCalendar</code> object.
      */
+    @Override
     public int hashCode() {
         return super.hashCode() ^ jdate.hashCode();
     }
@@ -368,6 +369,7 @@
      * or if any calendar fields have out-of-range values in
      * non-lenient mode.
      */
+    @Override
     public void add(int field, int amount) {
         // If amount == 0, do nothing even the given field is out of
         // range. This is tested by JCK.
@@ -496,6 +498,7 @@
         }
     }
 
+    @Override
     public void roll(int field, boolean up) {
         roll(field, up ? +1 : -1);
     }
@@ -520,6 +523,7 @@
      * @see #add(int,int)
      * @see #set(int,int)
      */
+    @Override
     public void roll(int field, int amount) {
         // If amount == 0, do nothing even the given field is out of
         // range. This is tested by JCK.
@@ -1758,12 +1762,12 @@
                     }
                 } else if (transitionYear) {
                     if (jdate.getYear() == 1) {
-                        // As of NewEra (since Meiji) there's no case
+                        // As of Reiwa (since Meiji) there's no case
                         // that there are multiple transitions in a
                         // year.  Historically there was such
                         // case. There might be such case again in the
                         // future.
-                        if (era > NEWERA) {
+                        if (era > REIWA) {
                             CalendarDate pd = eras[era - 1].getSinceDate();
                             if (normalizedYear == pd.getYear()) {
                                 d.setMonth(pd.getMonth()).setDayOfMonth(pd.getDayOfMonth());
--- a/src/share/classes/sun/text/resources/FormatData.java	Mon Apr 15 03:00:17 2019 +0100
+++ b/src/share/classes/sun/text/resources/FormatData.java	Mon Apr 15 04:35:08 2019 +0100
@@ -138,7 +138,7 @@
                     "Taisho",
                     "Showa",
                     "Heisei",
-                    "NewEra", // NewEra
+                    "Reiwa",
                 }
             },
             { "java.util.JapaneseImperialCalendar.short.Eras",
@@ -148,7 +148,7 @@
                     "T",
                     "S",
                     "H",
-                    "N", // NewEra
+                    "R",
                 }
             },
             { "java.util.JapaneseImperialCalendar.FirstYear",
--- a/src/share/classes/sun/text/resources/FormatData_ja.java	Mon Apr 15 03:00:17 2019 +0100
+++ b/src/share/classes/sun/text/resources/FormatData_ja.java	Mon Apr 15 04:35:08 2019 +0100
@@ -129,7 +129,7 @@
                     "\u5927\u6b63",     // Taisho
                     "\u662d\u548c",     // Showa
                     "\u5e73\u6210",     // Heisei
-                    "\u5143\u53f7",     // NewEra
+                    "\u4ee4\u548c",     // Reiwa
                 }
             },
             { "java.util.JapaneseImperialCalendar.FirstYear",
--- a/src/share/classes/sun/util/calendar/Era.java	Mon Apr 15 03:00:17 2019 +0100
+++ b/src/share/classes/sun/util/calendar/Era.java	Mon Apr 15 04:35:08 2019 +0100
@@ -41,21 +41,16 @@
  * <code>CalendarDate</code>.
  *
  * <p>The following era names are defined in this release.
- * <!-- TODO: use HTML table -->
- * <pre><tt>
+ * <pre>{@code
  *   Calendar system         Era name         Since (in Gregorian)
  *   -----------------------------------------------------------------------
- *   Japanese calendar       Meiji            1868-01-01 midnight local time
- *                           Taisho           1912-07-30 midnight local time
- *                           Showa            1926-12-26 midnight local time
- *                           Heisei           1989-01-08 midnight local time
- *                           NewEra           2019-05-01 midnight local time
- *   Julian calendar         BeforeCommonEra  -292275055-05-16T16:47:04.192Z
- *                           CommonEra        0000-12-30 midnight local time
- *   Taiwanese calendar      MinGuo           1911-01-01 midnight local time
- *   Thai Buddhist calendar  BuddhistEra      -543-01-01 midnight local time
+ *   Japanese calendar       Meiji            1868-01-01T00:00:00 local time
+ *                           Taisho           1912-07-30T00:00:00 local time
+ *                           Showa            1926-12-25T00:00:00 local time
+ *                           Heisei           1989-01-08T00:00:00 local time
+ *                           Reiwa            2019-05-01T00:00:00 local time
  *   -----------------------------------------------------------------------
- * </tt></pre>
+ * }</pre>
  *
  * @author Masayoshi Okutsu
  * @since 1.5
--- a/src/share/lib/calendars.properties	Mon Apr 15 03:00:17 2019 +0100
+++ b/src/share/lib/calendars.properties	Mon Apr 15 04:35:08 2019 +0100
@@ -29,14 +29,14 @@
 #   Taisho since 1912-07-30 00:00:00 local time (Gregorian)
 #   Showa  since 1926-12-25 00:00:00 local time (Gregorian)
 #   Heisei since 1989-01-08 00:00:00 local time (Gregorian)
-#   NewEra since 2019-05-01 00:00:00 local time (Gregorian)
+#   Reiwa  since 2019-05-01 00:00:00 local time (Gregorian)
 calendar.japanese.type: LocalGregorianCalendar
 calendar.japanese.eras: \
 	name=Meiji,abbr=M,since=-3218832000000;  \
 	name=Taisho,abbr=T,since=-1812153600000; \
 	name=Showa,abbr=S,since=-1357603200000;  \
 	name=Heisei,abbr=H,since=600220800000;   \
-	name=NewEra,abbr=N,since=1556668800000
+	name=Reiwa,abbr=R,since=1556668800000
 
 #
 # Taiwanese calendar
--- a/test/java/text/Format/DateFormat/WeekDateTest.java	Mon Apr 15 03:00:17 2019 +0100
+++ b/test/java/text/Format/DateFormat/WeekDateTest.java	Mon Apr 15 04:35:08 2019 +0100
@@ -137,9 +137,9 @@
         Calendar jcal = Calendar.getInstance(TimeZone.getTimeZone("GMT"),
                                              new Locale("ja", "JP", "JP"));
 
-        String format = "2-W01-2"; // 2019-12-31 == N1-12-31
+        String format = "2-W01-2"; // 2019-12-31 == R1-12-31
         int expectedYear = 2019;
-        // Check the current era, Heisei or NewEra
+        // Check the current era, Heisei or Reiwa
         if (System.currentTimeMillis() < 1556668800000L) {
             format = "21-W01-3"; // 2008-12-31 == H20-12-31
             expectedYear = 2008;
--- a/test/java/util/Calendar/CalendarTestScripts/CalendarAdapter.java	Mon Apr 15 03:00:17 2019 +0100
+++ b/test/java/util/Calendar/CalendarTestScripts/CalendarAdapter.java	Mon Apr 15 04:35:08 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 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
@@ -364,7 +364,7 @@
                 "Taisho",
                 "Showa",
                 "Heisei",
-                "NewEra"
+                "Reiwa"
             };
             break;
         }
--- a/test/java/util/Calendar/CalendarTestScripts/Symbol.java	Mon Apr 15 03:00:17 2019 +0100
+++ b/test/java/util/Calendar/CalendarTestScripts/Symbol.java	Mon Apr 15 04:35:08 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 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
@@ -322,7 +322,7 @@
         put("taisho", new Symbol(Type.ERA, 2));
         put("showa", new Symbol(Type.ERA, 3));
         put("heisei", new Symbol(Type.ERA, 4));
-        put("newera", new Symbol(Type.ERA, 5));
+        put("reiwa", new Symbol(Type.ERA, 5));
 
     }
 }
--- a/test/java/util/Calendar/CalendarTestScripts/japanese/japanese.cts	Mon Apr 15 03:00:17 2019 +0100
+++ b/test/java/util/Calendar/CalendarTestScripts/japanese/japanese.cts	Mon Apr 15 04:35:08 2019 +0100
@@ -57,7 +57,7 @@
 	check millisecond 0
 
 	clear all
-	set era NewEra
+	set era Reiwa
 	check era Heisei
 	check datetime 31 Jan 1 0 0 0
 	check millisecond 0
--- a/test/java/util/Calendar/CalendarTestScripts/japanese/japanese_add.cts	Mon Apr 15 03:00:17 2019 +0100
+++ b/test/java/util/Calendar/CalendarTestScripts/japanese/japanese_add.cts	Mon Apr 15 04:35:08 2019 +0100
@@ -16,10 +16,10 @@
 test add ERA
     use jcal
 	clear all
-	set date NewEra 17 Mar 8
+	set date Reiwa 17 Mar 8
 	add era 10
-	# as of NewEra 17 March 8
-	check era NewEra
+	# as of Reiwa 17 March 8
+	check era Reiwa
 	add era -100
 	check era BeforeMeiji
 
@@ -342,12 +342,12 @@
 	check date BeforeMeiji $minyear May 18
 	check timeofday 1 47 4 191
 
-	set date NewEra 17 Jan 1
+	set date Reiwa 17 Jan 1
 	get max year
 	assign $result $max
-	set date NewEra $max Jul 17
+	set date Reiwa $max Jul 17
 	add month 1
-	check date NewEra $max Aug 17
+	check date Reiwa $max Aug 17
 #	set date Heisei $max Jul 28
 #	set timeofday 23 59 59 999
 #	add month 1
--- a/test/java/util/Calendar/CalendarTestScripts/japanese/japanese_minmax.cts	Mon Apr 15 03:00:17 2019 +0100
+++ b/test/java/util/Calendar/CalendarTestScripts/japanese/japanese_minmax.cts	Mon Apr 15 04:35:08 2019 +0100
@@ -14,10 +14,10 @@
 
 test Make sure that the maximum year value doesn't depent on era
     use jcal
-	# Note: the max year value is as of NewEra
+	# Note: the max year value is as of Reiwa
 	assign 292276976 $max
 	clear all
-	set date NewEra 1 May 1
+	set date Reiwa 1 May 1
 	get millis
 	check max year $max
 	assign $max $maxyear
@@ -39,9 +39,9 @@
 
 test Max of ERA
     use jcal
-	# Assumption: NewEra is the current era
-	check maximum era NewEra
-	check leastmax era NewEra
+	# Assumption: Reiwa is the current era
+	check maximum era Reiwa
+	check leastmax era Reiwa
 
 test Actual max MONTH
     use jcal
@@ -78,7 +78,7 @@
 	check actualmax month Apr
 
 	clear all
-	set date NewEra 2 Jan 1
+	set date Reiwa 2 Jan 1
 	set year $maxyear
 	check actualmax month Aug
 	get millis
@@ -133,8 +133,8 @@
    # time zone dependent
    use tokyocal
 	clear all
-	set date NewEra $maxyear Jan 1
-	# the last date of NewEra is N292276976.08.17T16:12:55.807+0900
+	set date Reiwa $maxyear Jan 1
+	# the last date of Reiwa is R292276976.08.17T16:12:55.807+0900
 	check actualmax day_of_year 229 # 31+28+31+30+31+30+31+17
 
 test Actual max WEEK_OF_YEAR
@@ -165,12 +165,12 @@
 	clear all
 	set date Heisei 31 Apr 28
 	check actualmax week_of_year 17
-	set date NewEra 1 Aug 9
+	set date Reiwa 1 Aug 9
 	check actualmax week_of_year 35
 
     use tokyocal
-	set date NewEra $maxyear Jan 1
-	# the last date of NewEra is N292276976.08.17T16:12:55.807+0900 (Sunday)	
+	set date Reiwa $maxyear Jan 1
+	# the last date of Reiwa is R292276976.08.17T16:12:55.807+0900 (Sunday)	
 	# The year is equivalent to 2003 (Gregorian).
 	check actualmax week_of_year 34
 
@@ -197,12 +197,12 @@
 	clear all
 	set date Heisei 31 Apr 30
 	check actualmax week_of_month 5
-	set date NewEra 1 May 1
+	set date Reiwa 1 May 1
 	check actualmax week_of_month 5
 
     use tokyocal
-	set date NewEra $maxyear Jan 1
-	# the last date of NewEra is N292276976.08.17T16:12:55.807+0900 (Sunday)	
+	set date Reiwa $maxyear Jan 1
+	# the last date of Reiwa is R292276976.08.17T16:12:55.807+0900 (Sunday)	
 	# The year is equivalent to 2003 (Gregorian).
 	check actualmax week_of_month 4
 	
@@ -229,13 +229,13 @@
 	clear all
 	set date Heisei 31 Apr 30
 	check actualmax week_of_month 5
-	set date NewEra 1 May 1
+	set date Reiwa 1 May 1
 	check actualmax week_of_month 5
 
     use tokyocal
 	clear all
-	set date NewEra $maxyear Jan 1
-	# the last date of NewEra is N292276976.08.17T16:12:55.807+0900 (Sunday)	
+	set date Reiwa $maxyear Jan 1
+	# the last date of Reiwa is R292276976.08.17T16:12:55.807+0900 (Sunday)	
 	# The year is equivalent to 2003 (Gregorian).
 	check actualmax week_of_month 4
 
@@ -269,11 +269,11 @@
 	set date Heisei 1 Aug 18
 	check actualmax year 30
 
-	set date NewEra 1 Apr 30
+	set date Reiwa 1 Apr 30
 	check actualmax year 31
 
 	# Date/time beyond the last date in the max year.
-	set date NewEra 1 Aug 18
+	set date Reiwa 1 Aug 18
 	check actualmax year 292276975
 	
 test Least max YEAR
--- a/test/java/util/Calendar/CalendarTestScripts/japanese/japanese_roll.cts	Mon Apr 15 03:00:17 2019 +0100
+++ b/test/java/util/Calendar/CalendarTestScripts/japanese/japanese_roll.cts	Mon Apr 15 04:35:08 2019 +0100
@@ -147,13 +147,13 @@
 	roll year -1
 	check date Heisei 31 Apr 30
 
-	set date NewEra 2 Apr 30
+	set date Reiwa 2 Apr 30
 	get max year
 	assign $result $hmax
 	roll year -1
-	check date NewEra $hmax Apr 30
+	check date Reiwa $hmax Apr 30
 	roll year 1
-	check date NewEra 2 Apr 30
+	check date Reiwa 2 Apr 30
 
 test roll MONTH
 	set date BeforeMeiji 1867 Dec 1
@@ -276,16 +276,16 @@
 	check date BeforeMeiji $minyear May 18
 	check timeofday 1 47 4 191
 
-	set date NewEra 17 Jan 1
+	set date Reiwa 17 Jan 1
 	get max year
 	assign $result $max
-	set date NewEra $max Jul 28
+	set date Reiwa $max Jul 28
 	roll month 1
-	check date NewEra $max Aug 17
-	set date NewEra $max Jul 28
+	check date Reiwa $max Aug 17
+	set date Reiwa $max Jul 28
 	set timeofday 23 59 59 999
 	roll month 1
-	check date NewEra $max Aug 16
+	check date Reiwa $max Aug 16
 	check timeofday 23 59 59 999
 
 test roll WEEK_OF_YEAR
--- a/test/java/util/Calendar/JapaneseEraNameTest.java	Mon Apr 15 03:00:17 2019 +0100
+++ b/test/java/util/Calendar/JapaneseEraNameTest.java	Mon Apr 15 04:35:08 2019 +0100
@@ -54,12 +54,12 @@
     Object[][] names() {
         return new Object[][] {
             // type,    locale,  name
-            { LONG,     JAPAN,   "\u5143\u53f7" }, // NewEra
-            { LONG,     US,      "NewEra" },
-            { LONG,     CHINA,   "NewEra" },
-            { SHORT,    JAPAN,   "N" },
-            { SHORT,    US,      "N" },
-            { SHORT,    CHINA,   "N" },
+            { LONG,     JAPAN,   "\u4ee4\u548c" },
+            { LONG,     US,      "Reiwa" },
+            { LONG,     CHINA,   "Reiwa" },
+            { SHORT,    JAPAN,   "R" },
+            { SHORT,    US,      "R" },
+            { SHORT,    CHINA,   "R" },
         };
     }
 
--- a/test/java/util/Calendar/JapaneseLenientEraTest.java	Mon Apr 15 03:00:17 2019 +0100
+++ b/test/java/util/Calendar/JapaneseLenientEraTest.java	Mon Apr 15 04:35:08 2019 +0100
@@ -47,7 +47,7 @@
             // lenient era/year, strict era/year
             { "Meiji 123", "Heisei 2" },
             { "Showa 65", "Heisei 2" },
-            { "Heisei 32", "NewEra 2" }, // NewEra
+            { "Heisei 32", "Reiwa 2" },
         };
     }