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

With CLDR provider, DecimalFormatSymbols.getInstance(locale) could not handle locale with nu extension correctly.

XMLWordPrintable

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

      Sample code snippet:
      public static void main(String[] args){
              List<String> langList = new ArrayList<String>();
              langList.add("de-DE");
              langList.add("de-DE-u-nu-deva");
              for(String langTag: langList) {
                  Locale locale = Locale.forLanguageTag(langTag);
                  DecimalFormatSymbols dfs = DecimalFormatSymbols.getInstance(locale);
                  Character decimal = Character.valueOf(dfs.getDecimalSeparator());
                  Character group = Character.valueOf(dfs.getGroupingSeparator());
                  System.out.println("locale: " + langTag + " decimal: [" + decimal + "] group: [" + group + "]");
              }
          }

      For de-DE-u-nu-deva, there is no number system defined for "deva" in de-DE and de, my understanding is it should fallback to 'latn' in de, and have the same output with de-DE, but it seems not.
      Locale de-DE-u-nu-deva is an example, it also failed on other locales when number system specified by 'nu' does not exist in the corresponding CLDR xml.

      CLDR spec:
      <symbols numberSystem="deva">
                  <alias source="locale" path="../symbols[@numberSystem='latn']"/>
      </symbols>
      de.xml:
      <symbols numberSystem="latn">
      <decimal>,</decimal>
      <group>.</group>
                              ...
      </symbols>

      Expected:
      locale: de-DE decimal: [,] group: [.]
      locale: de-DE-u-nu-deva decimal: [,] group: [.]

      Output:
      locale: de-DE decimal: [,] group: [.]
      locale: de-DE-u-nu-deva decimal: [.] group: [,]

            naoto Naoto Sato
            dzhou Dora Zhou (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: