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

Accounting currency format support does not cope with explicit number system

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P4
    • 14
    • 14
    • core-libs
    • b14
    • Verified

    Description

      Test JDK: jdk 14 build 11

      Run following code with -Djava.locale.providers=CLDR:
      public static void main(String[] args) {
      String langTag = "zh-CN-u-nu-arab-cf-account";
      NumberFormat cf = NumberFormat.getCurrencyInstance(Locale.forLanguageTag(langTag));
              String output = cf.format(-1234);
      System.out.println("zh-CN-u-nu-arab-cf-account: " + output);
      langTag = "ar-SA-u-cf-account";
      cf = NumberFormat.getCurrencyInstance(Locale.forLanguageTag(langTag));
              output = cf.format(-1234);
      System.out.println("ar-SA-u-cf-account: " + output);
      }

      Output: Parentheses for negative currency amounts. Please refer to attachment result.jpg.
      Expect: Default minus sign for negative currency amounts.

      When with CLDR provider specified, for locale "zh-CN-u-nu-arab-cf-account", "zh_CN" is not supported by CLDR, it falls back to the language only CLDR locale resource (zh.xml)
      In CLDR zh.xml:
               <currencyFormats numberSystem="arab">
                   <currencyFormatLength>
                       <currencyFormat type="standard">
                           <pattern>¤#,##0.00</pattern>
                       </currencyFormat>
                       <currencyFormat type="accounting">
                           <pattern draft="contributed">¤#,##0.00</pattern>
                       </currencyFormat>
                   </currencyFormatLength>
               </currencyFormats>

      Under currencyFormats with "arab" numberSystem, it does not have a explicit pattern for negative currency amounts, my understanding is it should use a minus sign as a default, not a parentheses.

      For locale "ar-SA-u-cf-account", in CLDR ar-SA.xml, no currencyFormats with "arab" numberSystem, based on the CLDR fallback mechanism, it should also use a minus sign as a default.

      Attachments

        1. result.JPG
          26 kB
          Dora Zhou
        2. Test.java
          0.5 kB
          Dora Zhou

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved: