<i18n dev> RFR: 8358819: The first year is not displayed correctly in Japanese Calendar
Justin Lu
jlu at openjdk.org
Wed Jun 11 07:49:29 UTC 2025
On Tue, 10 Jun 2025 18:36:15 GMT, Naoto Sato <naoto at openjdk.org> wrote:
> This regression was introduced by the removal of the COMPAT locale provider, which partially broke support for the first year in the Japanese calendar. In the Japanese calendar system, the first year of an era should be formatted using the character "元" rather than the numeral "1". The issue arises from a difference in how pattern character lengths are interpreted between CLDR and SimpleDateFormat. The existing `JapaneseEraNameTest` has been updated to cover this fix.
OK, I think I understand the general idea. Japanese Imperial Calendar only returns 元 for first year display name when the style is LONG.
// "GanNen" is supported only in the LONG style.
if (field == YEAR
&& (getBaseStyle(style) != LONG || fieldValue != 1 || get(ERA) == 0)) {
return null;
}
Thus, when `SimpleDateFormat`s rely on the underlying Japanese Calendar, they fetch incorrect results since their CLDR pattern defaults to "y" for LONG and FULL, unlike COMPAT which was "yyyy".
So we are updating the CLDRConverter to adapt the old COMPAT style pattern: "yyyy" when using Japanese calendar for LONG or FULL `SimpleDateFormat` patterns, such that it can replicate the old "gannen" style which emits the 元.
Marked as reviewed by jlu (Committer).
-------------
PR Review: https://git.openjdk.org/jdk/pull/25732#pullrequestreview-2916023605
PR Review: https://git.openjdk.org/jdk/pull/25732#pullrequestreview-2916024618
More information about the i18n-dev
mailing list