提交 5689bd19 编写于 作者: N naoto

8219890: Calendar.getDisplayName() returns empty string for new Japanese Era on some locales

Reviewed-by: lancea
上级 86fdb82b
...@@ -992,9 +992,11 @@ class JapaneseImperialCalendar extends Calendar { ...@@ -992,9 +992,11 @@ class JapaneseImperialCalendar extends Calendar {
String name = CalendarDataUtility.retrieveFieldValueName(getCalendarType(), field, String name = CalendarDataUtility.retrieveFieldValueName(getCalendarType(), field,
fieldValue, style, locale); fieldValue, style, locale);
// If the ERA value is null, then // If the ERA value is null or empty, then
// try to get its name or abbreviation from the Era instance. // try to get its name or abbreviation from the Era instance.
if (name == null && field == ERA && fieldValue < eras.length) { if ((name == null || name.isEmpty()) &&
field == ERA &&
fieldValue < eras.length) {
Era era = eras[fieldValue]; Era era = eras[fieldValue];
name = (style == SHORT) ? era.getAbbreviation() : era.getName(); name = (style == SHORT) ? era.getAbbreviation() : era.getName();
} }
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
/* /*
* @test * @test
* @bug 8202088 8207152 8217609 * @bug 8202088 8207152 8217609 8219890
* @summary Test the localized Japanese new era name (May 1st. 2019-) * @summary Test the localized Japanese new era name (May 1st. 2019-)
* is retrieved no matter CLDR provider contains the name or not. * is retrieved no matter CLDR provider contains the name or not.
* @run main/othervm -Djava.locale.providers=CLDR JapaneseEraNameTest * @run main/othervm -Djava.locale.providers=CLDR JapaneseEraNameTest
...@@ -49,8 +49,10 @@ public class JapaneseEraNameTest { ...@@ -49,8 +49,10 @@ public class JapaneseEraNameTest {
// temporarily. Will be fixed as part of JDK-8220020. // temporarily. Will be fixed as part of JDK-8220020.
// { LONG, JAPAN, "\u5143\u53f7" }, // { LONG, JAPAN, "\u5143\u53f7" },
{ LONG, US, "NewEra" }, { LONG, US, "NewEra" },
{ LONG, CHINA, "NewEra" },
{ SHORT,JAPAN, "\u5143\u53f7" },// NewEra { SHORT,JAPAN, "\u5143\u53f7" },// NewEra
{ SHORT,US, "NewEra" }, { SHORT,US, "NewEra" },
{ SHORT,CHINA, "N" },
}; };
public static void main(String[] args) { public static void main(String[] args) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册