mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-14 17:24:01 +00:00
ICU-20536 Japanese era Reiwa support in ICU4J 62
This commit is contained in:
parent
2474d75e25
commit
8fc7cb9cb7
3 changed files with 34 additions and 10 deletions
|
@ -1,3 +1,3 @@
|
|||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:4a4454ca40c65756c0bb6bb54195e36035e3a8ab532d56a909b5553df3ad601c
|
||||
size 12508686
|
||||
oid sha256:2c67d0aeed178a6583457ffc4a1a0edab65efa10d28556ed3a2b3a832702fde5
|
||||
size 12506918
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:a9a43c719aad250cf135f834d00c752cf3b08fdeee2469084d363f9bffd6b204
|
||||
size 813186
|
||||
oid sha256:78d557ff9bbcc0b171df4c9de959ef7435f76cbcb1643e57aee9c2aba41bd7b9
|
||||
size 725226
|
||||
|
|
|
@ -154,9 +154,9 @@ public class JapaneseTest extends CalendarTestFmwk {
|
|||
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 class JapaneseTest extends CalendarTestFmwk {
|
|||
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 class JapaneseTest extends CalendarTestFmwk {
|
|||
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 class JapaneseTest extends CalendarTestFmwk {
|
|||
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,29 @@ public class JapaneseTest extends CalendarTestFmwk {
|
|||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue