Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8185485

Java can't return exact dayPeriod value on some locales.

    Details

    • Type: Bug
    • Status: Open
    • Priority: P4
    • Resolution: Unresolved
    • Affects Version/s: 9
    • Fix Version/s: tbd
    • Component/s: core-libs
    • Labels:

      Description

      The issue exists on locale:"ur", "ur-IN", "ur-PK", "ug", "ug-CN", "te", "te-IN", "pt-MO", "ko", "ko-KP", "ko-KR", "kn", "kn-IN", "hi", "hi-IN", "bn", "bn-BD", "bn-IN".

      For example on ko locale. To get dayPeriod symbol 'a", there are both abbreviated and wide dayPeriod types in the ko.xml file, as CLDR defined it should get the abbreviated type, but actually Java return the wide type.

      Use below code to get Java's output. Java's output is 96. 2. 8. 오전 11:45, but as CLDR defined. should be 96. 2. 8. AM 11:45
      --------------------------------
      Locale target = Locale.forLanguageTag("ko");
      String format = FormatStyle.SHORT.toString();
      LocalDateTime dateTime = LocalDateTime
                      .of(Integer.parseInt("1996"), Integer.parseInt("2"),
                              Integer.parseInt("8"), Integer.parseInt("11"),
                              Integer.parseInt("45"), Integer.parseInt("8"));
      DateTimeFormatter formatter = DateTimeFormatter
                      .ofLocalizedDateTime(FormatStyle.valueOf(format));
      formatter = formatter.withLocale(target);
      String actualResult = dateTime.format(formatter);
      System.out.println(actualResult);
      -----------------------------------

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                naoto Naoto Sato
                Reporter:
                yzhou Daisy Zhou
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated: