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

Java fallback of DateFormat looks incorrect on some locales

XMLWordPrintable

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

      1. On sw-CD locale:
          Month abbreviated and stand-alone abbreviated fallback incorrect. For example, the input data is: testMonth = "1";
      test MonthDay stand-alone Abbreviated Format. There is no stand-alone abbreviated type in sw_CD.xml file, so should fallback to sw.xml as CLDR defined and get the result 'Jan', but actually Java return 'mkw' which is abbreviated type in sw_CD.xml file.
      Use below code to get java's output.
      ----------------------------------------
      String tag = "sw-CD";
      Locale target = Locale.forLanguageTag(tag);
      MonthDay date = MonthDay.of(Integer.parseInt("1"), Integer.parseInt("5"));
      String mPattern="LLL";
      DateTimeFormatter formatter = DateTimeFormatter.ofPattern(mPattern, target);
      formatter = formatter.withLocale(target);
      String actualResult = date.format(formatter);
      System.out.println(actualResult);
      -----------------------------------------
      This issue also happens on stand-alone wide type of sw_CD locale and below behaviors.
      2. on es_US locale:
      dayPeriod value with abbreviated type fallback incorrect. For example: the input data is: testYear = "1996";testMonth = "2";testDay = "8";testHour = "11";testMinute = "45";testSecond = "8";
      Test LocalDateTime with Short format. There is no abbreviated dayPeriod type in es_US.xml file, so should fallback to es_419.xml as CLDR defined and get the result 'a.m.', but actually Java return 'AM' which is wide type in es_US.xml file.
             

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

              Created:
              Updated: