<i18n dev> RFR: 8262108: SimpleDateFormat formatting broken for sq_MK Locale [v3]

Jaikiran Pai jpai at openjdk.java.net
Wed Apr 14 17:18:44 UTC 2021

On Wed, 14 Apr 2021 17:14:55 GMT, Jaikiran Pai <jpai at openjdk.org> wrote:

>> Can I please get a review for this proposed fix for https://bugs.openjdk.java.net/browse/JDK-8262108?
>> As noted in a comment in that issue, the bug relates to the return value of `Calendar.getDisplayNames` for the `Calendar.AM_PM` field. The implementation has started returning invalid values for the `AM_PM` field after the "day period" support was added recently in the JDK as part of https://bugs.openjdk.java.net/browse/JDK-8262108.
>> The commit here adds a check in the internal implementation of the display name handling logic, to special case the `AM_PM` field and properly convert the display name array indexes (which is an internal detail) to valid values that represent the `AM_PM` calendar field.
>> The commit also has a new jtreg test case `CalendarDisplayNamesTest` reproduces this issue and verifies the fix.
>> After this fix was introduced, I ran the test in `test/jdk/java/util/Calendar/` and that showed up a failure in an existing test case `NarrowNamesTest`. Looking at that test case, IMO, the current testing in that `NarrowNamesTest` is incorrect and is probably what hid this issue in the first place? To fix this, I have added an additional commit which updates this test case to properly test the `AM_PM` field values.
> Jaikiran Pai has updated the pull request incrementally with two additional commits since the last revision:
>  - Update existing NarrowNamesTest to match expectations
>  - Naoto's review suggestion

Hello Naoto,

> CalendarNameProviderImpl is an implementation detail, which is shared between j.u.Calendar and j.t.f.DateTimeFormatter(Builder) class, where it provides localized names for Calendar fields. For the field Calendar.AM_PM, it includes not only am/pm translations, but also day periods translations as you see.

Thank you for those details. That's very helpful.

>I'd rather modify the code like:

                            if (field == AM_PM && !javatime && i > PM) {
                            } else {
                                map.put(name, base + i);

I've taken your suggestion and updated the code to match this. In the update, I've included a code comment to explain what this block does. Please do let me know if that code comment isn't accurate and needs any updates.

 The new `CalendarDisplayNamesTest` continues to pass with this change. I updated the existing `NarrowNamesTest` to match the expectations of the `Calendar.getDisplayName()` API.

All jtreg tests in `test/jdk/java/util/Calendar` and `test/jdk/java/time/` continue to pass too. I have triggered a local run of `tier1` tests and will check back the results early morning tomorrow.

Thank you for your reviews so far.


PR: https://git.openjdk.java.net/jdk/pull/3463

More information about the i18n-dev mailing list