diff --git a/icu4j/main/classes/core/src/com/ibm/icu/util/JapaneseCalendar.java b/icu4j/main/classes/core/src/com/ibm/icu/util/JapaneseCalendar.java index 5463407eb55a..a7f23a41daca 100644 --- a/icu4j/main/classes/core/src/com/ibm/icu/util/JapaneseCalendar.java +++ b/icu4j/main/classes/core/src/com/ibm/icu/util/JapaneseCalendar.java @@ -562,6 +562,7 @@ protected void handleComputeFields(int julianDay) { 1912, 7, 30, // Taisho 1926, 12, 25, // Showa 1989, 1, 8, // Heisei + 2019, 5, 1, // Reiwa }; //------------------------------------------------------------------------- @@ -578,25 +579,25 @@ protected void handleComputeFields(int julianDay) { * Constant for the era starting on Sept. 8, 1868 AD. * @stable ICU 2.8 */ - static public final int MEIJI = CURRENT_ERA - 3; + static public final int MEIJI = CURRENT_ERA - 4; /** * Constant for the era starting on July 30, 1912 AD. * @stable ICU 2.8 */ - static public final int TAISHO = CURRENT_ERA - 2; + static public final int TAISHO = CURRENT_ERA - 3; /** * Constant for the era starting on Dec. 25, 1926 AD. * @stable ICU 2.8 */ - static public final int SHOWA = CURRENT_ERA - 1; + static public final int SHOWA = CURRENT_ERA - 2; /** * Constant for the era starting on Jan. 7, 1989 AD. * @stable ICU 2.8 */ - static public final int HEISEI = CURRENT_ERA; + static public final int HEISEI = CURRENT_ERA - 1; /** * Override GregorianCalendar. We should really handle YEAR_WOY and diff --git a/icu4j/main/shared/data/icudata.jar b/icu4j/main/shared/data/icudata.jar index 1ab46f1d820b..ffaa0e003b32 100755 --- a/icu4j/main/shared/data/icudata.jar +++ b/icu4j/main/shared/data/icudata.jar @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:3eb8332f908b83c82671f2b652d0bfdcc1c8da416884d0e358464af42af4f959 -size 12505745 +oid sha256:260e1561108b1697fe8f5f97b539c4fd333a65fb1f6a77eeb82f76047c7005ea +size 12506005 diff --git a/icu4j/main/shared/data/testdata.jar b/icu4j/main/shared/data/testdata.jar index d3a3686cffe1..5dafffde5026 100755 --- a/icu4j/main/shared/data/testdata.jar +++ b/icu4j/main/shared/data/testdata.jar @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:9d6f74e0bb0de91023fcf6b0aec8acab619da6854baae4609b0808bb7dcec9d2 -size 813161 +oid sha256:1feac30561884a72f1b05f54912e50b6bf20532243b12a976e34756a59ec1111 +size 813168 diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/calendar/JapaneseTest.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/calendar/JapaneseTest.java index 6ec96f48c3ba..34f63c297df6 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/calendar/JapaneseTest.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/calendar/JapaneseTest.java @@ -154,9 +154,9 @@ public void Test3860() Calendar cal = new JapaneseCalendar(loc); DateFormat enjformat = cal.getDateTimeFormat(0,0,new ULocale("en_JP@calendar=japanese")); DateFormat format = cal.getDateTimeFormat(0,0,loc); - ((SimpleDateFormat)format).applyPattern("y.M.d"); // Note: just 'y' doesn't work here. + ((SimpleDateFormat)format).applyPattern("y/M/d"); // Note: just 'y' doesn't work here. ParsePosition pos = new ParsePosition(0); - Date aDate = format.parse("1.1.9", pos); // after the start of heisei accession. Jan 1, 1H wouldn't work because it is actually showa 64 + Date aDate = format.parse("1/5/9", pos); // after the start of Reiwa accession. Jan 1, R1 wouldn't work because it is actually Heisei 31 String inEn = enjformat.format(aDate); cal.clear(); @@ -165,7 +165,7 @@ public void Test3860() int gotEra = cal.get(Calendar.ERA); int expectYear = 1; - int expectEra = JapaneseCalendar.CURRENT_ERA; + int expectEra = JapaneseCalendar.CURRENT_ERA; // Reiwa if((gotYear != expectYear) || (gotEra != expectEra)) { errln("Expected year " + expectYear + ", era " + expectEra +", but got year " + gotYear + " and era " + gotEra + ", == " + inEn); @@ -173,7 +173,7 @@ public void Test3860() logln("Got year " + gotYear + " and era " + gotEra + ", == " + inEn); } - // Test parse with missing era (should default to current era, heisei) + // Test parse with missing era (should default to current era) // Test parse with incomplete information logln("Testing parse w/ just year..."); Calendar cal2 = new JapaneseCalendar(loc); @@ -197,7 +197,7 @@ public void Test3860() gotYear = cal2.get(Calendar.YEAR); gotEra = cal2.get(Calendar.ERA); expectYear = 1; - expectEra = JapaneseCalendar.CURRENT_ERA; + expectEra = JapaneseCalendar.CURRENT_ERA; // Reiwa if((gotYear != 1) || (gotEra != expectEra)) { errln("parse "+ samplestr + " of 'y' as Japanese Calendar, expected year " + expectYear + " and era " + expectEra + ", but got year " + gotYear + " and era " + gotEra + " (Gregorian:" + str +")"); @@ -379,5 +379,30 @@ public void TestLimits() { doLimitsTest(jcal, null, cal.getTime()); doTheoreticalLimitsTest(jcal, true); } + + public void TestHeiseiToReiwa() { + Calendar cal = Calendar.getInstance(); + cal.set(2019, Calendar.APRIL, 29); + + DateFormat jfmt = DateFormat.getDateInstance(DateFormat.LONG, new ULocale("ja@calendar=japanese")); + + final String[] EXPECTED_FORMAT = { + "\u5E73\u621031\u5E744\u670829\u65E5", // Heisei 31 April 29 + "\u5E73\u621031\u5E744\u670830\u65E5", // Heisei 31 April 30 + "\u4EE4\u548C1\u5E745\u67081\u65E5", // Reiwa 1 May 1 + "\u4EE4\u548C1\u5E745\u67082\u65E5", // Reiwa 1 May 2 + }; + + for (int i = 0; i < EXPECTED_FORMAT.length; i++) { + Date d = cal.getTime(); + String dateStr = jfmt.format(d); + if (!EXPECTED_FORMAT[i].equals(dateStr)) { + errln("Formatting year:" + cal.get(Calendar.YEAR) + " month:" + (cal.get(Calendar.MONTH) + 1) + + " day:" + cal.get(Calendar.DATE) + " - expected: " + EXPECTED_FORMAT[i] + + " / actual: " + dateStr); + } + cal.add(Calendar.DATE, 1); + } + } }