8219890: Calendar.getDisplayName() returns empty string for new Japanese Era on some locales
Reviewed-by: lancea
This commit is contained in:
parent
29d842b5a0
commit
c12d6ac1a7
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2005, 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
|
||||
@ -1022,9 +1022,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.
|
||||
* @modules jdk.localedata
|
||||
@ -53,8 +53,10 @@ public class JapaneseEraNameTest {
|
||||
// type, locale, name
|
||||
{ LONG, JAPAN, "\u5143\u53f7" }, // NewEra
|
||||
{ LONG, US, "NewEra" },
|
||||
{ LONG, CHINA, "NewEra" },
|
||||
{ SHORT, JAPAN, "\u5143\u53f7" },
|
||||
{ SHORT, US, "NewEra" },
|
||||
{ SHORT, CHINA, "N" },
|
||||
};
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user