JDK-8227313 : Support monetary grouping separator in DecimalFormat/DecimalFormatSymbols
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.text
  • Affected Version: 11,12,13,14
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2019-07-03
  • Updated: 2020-01-11
  • Resolved: 2020-01-06
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 15
15 b05Fixed
Related Reports
CSR :  
Sub Tasks
JDK-8236687 :  
Description
ADDITIONAL SYSTEM INFORMATION :
Win10
jdk11.0.3


A DESCRIPTION OF THE PROBLEM :
The unicode standard defines a currency grouping separator with de_AT (see https://www.unicode.org/cldr/charts/33/by_type/numbers.symbols.html#Symbols_). It is not possible to use the correct grouping separator when dealing with monetary values. For de_AT the monetary grouping separator is a dot '.', the number grouping separator is a blank ' '. 

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
    public static void main(String[] args) {
        Double number = 1500D;
        NumberFormat format = NumberFormat.getCurrencyInstance(new Locale("de", "AT"));
        String currency = format.format(number);
        System.out.println("Currency in Austria : Must be '����������1.500,00' but is '" + currency + "'");
    }

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Methods
- DecimalFormatSymbols.getMonetaryGroupingSeparator()
- DecimalFormatSymbols.setMonetaryGroupingSeparator(char)
must exist.
ACTUAL -
At the moment the unicode standard for Austria cannot be applied correctly. 

---------- BEGIN SOURCE ----------
    public static void main(String[] args) {
        Double number = 1500D;
        NumberFormat format = NumberFormat.getCurrencyInstance(new Locale("de", "AT"));
        String currency = format.format(number);
        System.out.println("Currency in Austria : Must be '������ 1.500,00' but is '" + currency + "'");
    }
---------- END SOURCE ----------


Comments
URL: https://hg.openjdk.java.net/jdk/jdk/rev/d8fbcf86ce72 User: naoto Date: 2020-01-06 18:40:54 +0000
06-01-2020

Swiss French has the similar issue with currency decimal separator, where it is "." but normal decimal is ",". It should be fixed as well. Although DecimalFormatSymbols.get/setMonetaryDecimalSeparator() is already in JDK, CLDR resources fail to provide the separator based on the need (generic/currency).
16-12-2019

LDML defines yet another Number Symbol, i.e., "timeSeparator": https://unicode.org/reports/tr35/tr35-numbers.html#Number_Symbols However, it reads: --- timeSeparator - This replaces any use of the timeSeparator pattern character in a date-time format pattern (no timeSeparator pattern character is currently defined, see note below). This allows the same time format to be used for multiple number systems when the time separator depends on the number system. For example, the time format for Arabic should be COLON when using the Latin numbering system (0, 1, 2, ���), but when the Arabic numbering system is used (����� - ����� - ����� ���), the traditional time separator in older print styles was often ARABIC COMMA. Note: In CLDR 26 the timeSeparator pattern character was specified to be COLON. This was withdrawn in CLDR 28 due to backward compatibility issues, and no timeSeparator pattern character is currently defined. No CLDR locales are known to have a need to specify timeSeparator symbols that depend on number system; if this changes in the future a different timeSeparator pattern character will be defined. In the meantime, since CLDR data consumers can still request the timeSeparator symbol. it should match the symbol actually used in the timeFormats and availableFormats items. --- IIUC, currently there is no need to support timeSeparator as of CLDR 36, since there is no pattern character defined for timeSeparator symbol, i.e., no substitution with timeSeparator is required. Thus, supporting "currencyDecimal" and "currencyGroup" will suffice to upgrade JDK's support to the current LDML spec.
16-12-2019

Looking at the CLDR, the only locale that needs currency grouping separator differing from normal grouping separator is de-AT. I prefer not to introduce this public API, but simply retrieving the currency grouping separator from the resource should suffice the need.
12-12-2019

According to [~yan], a customer at Azul wanted this feature too.
06-12-2019

To reproduce the issue, run the attached test case. JDK 11.0.3 - Fail JDK 13-ea + 22 - Fail Output: Currency in Austria : Must be '��� 1.500,00' but is '�����1��500,00'
05-07-2019