JDK-8218770 : Accounting currency format support
  • Type: CSR
  • Component: core-libs
  • Sub-Component: java.text
  • Priority: P4
  • Status: Closed
  • Resolution: Approved
  • Fix Versions: 14
  • Submitted: 2019-02-11
  • Updated: 2019-08-05
  • Resolved: 2019-08-05
Related Reports
CSR :  
Description
Summary
-------

Implement the [currency format style Unicode extension][1] defined in LDML.

Problem
-------

Currently, the default currency format for the negative amounts simply prepends the minus sign to the amounts with the CLDR locale provider. Since the legacy COMPAT locale provider has been formatting the currency amounts in parentheses in some locales, it is considered a [regression in CLDR locale provider][2].

Solution
--------

LDML defines the currency format style extension "cf" which designates the style of the currency formatting. The default style "standard" is used in the JDK which prepends the minus sign to the negative amounts. Alternatively, LDML/CLDR provides currency formats with negative values in parentheses as "accounting" format. By supporting this "accounting" style, applications can use the parentheses style negative amounts with CLDR provider. 
For this purpose,  `java.text.NumberFormat#getCurrencyInstance(Locale)` will return an appropriate format object based on the given locale's "cf" extension. The default style, i.e., without "cf" extension, will use the "standard" formatting style for the compatibility. Applications that expect the "accounting" style currency formatting will need to specify it explicitly with the `locale` argument.

Specification
-------------

Insert the following paragraph in `java.text.NumberFormat#getCurrencyInstance(Locale)` method description:

     * <p>If the specified locale contains the "{@code cf}" (
     * <a href="https://www.unicode.org/reports/tr35/tr35.html#UnicodeCurrencyFormatIdentifier">
     * currency format style</a>)
     * <a href="../util/Locale.html#def_locale_extension">Unicode extension</a>,
     * the returned currency format uses the style if it is available. 
     * Otherwise, the style uses the default "{@code standard}" currency format.
     * For example, if the style designates "{@code account}", negative
     * currency amounts use a pair of parentheses in some locales. 

  [1]: http://www.unicode.org/reports/tr35/#UnicodeCurrencyFormatIdentifier
  [2]: https://bugs.openjdk.java.net/browse/JDK-8221245
Comments
Moving to Approved.
05-08-2019