mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 14:54:52 +02:00
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
2 changed files with 8 additions and 4 deletions
|
@ -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.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* 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,
|
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 @@
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @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.
|
||||||
* @modules jdk.localedata
|
* @modules jdk.localedata
|
||||||
|
@ -53,8 +53,10 @@ public class JapaneseEraNameTest {
|
||||||
// type, locale, name
|
// type, locale, name
|
||||||
{ LONG, JAPAN, "\u5143\u53f7" }, // NewEra
|
{ LONG, JAPAN, "\u5143\u53f7" }, // NewEra
|
||||||
{ LONG, US, "NewEra" },
|
{ LONG, US, "NewEra" },
|
||||||
|
{ LONG, CHINA, "NewEra" },
|
||||||
{ SHORT, JAPAN, "\u5143\u53f7" },
|
{ SHORT, JAPAN, "\u5143\u53f7" },
|
||||||
{ SHORT, US, "NewEra" },
|
{ SHORT, US, "NewEra" },
|
||||||
|
{ SHORT, CHINA, "N" },
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue