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

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

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P4 P4
    • tbd
    • 9
    • core-libs

      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);
      -----------------------------------

            naoto Naoto Sato
            yzhou Daisy Zhou (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: