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

Accounting currency format support does not cope with explicit number system

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 14
    • Fix Version/s: 14
    • Component/s: core-libs
    • Labels:
    • Subcomponent:
    • Resolved In Build:
      b14
    • Verification:
      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
          result.JPG
          26 kB
        2. Test.java
          0.5 kB

          Issue Links

            Activity

              People

              • Assignee:
                naoto Naoto Sato
                Reporter:
                dzhou Dora Zhou
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: