提交 9a3f61f6 编写于 作者: N naoto

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

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