JDK-8222756 : Plural support in CompactNumberFormat
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.util:i18n
  • Affected Version: 12,13,14
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2019-04-15
  • Updated: 2022-07-13
  • Resolved: 2019-12-05
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 14
14 b27Fixed
Related Reports
CSR :  
Relates :  
Sub Tasks
JDK-8235444 :  
Description
ADDITIONAL SYSTEM INFORMATION :
All OS affected, JDK 12 affected.

A DESCRIPTION OF THE PROBLEM :
CompactNumberFormat return wrong texts for many languages that use the plural form for numbers.
E.g. German: 1_000_000 is '1 Million' (correct in JDK 12), 2_000_000 should be '2 Millionen' but the result is '2 Milion').
Same for Italian: 1_000_000 is '1 millione' (correct in JDK 12), 2_000_000 should be '2 milioni' but the result is '2 milione'. 

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
 NumberFormat compactNumberFormat = CompactNumberFormat.getCompactNumberInstance(Locale.GERMAN, NumberFormat.Style.LONG);
System.out.println(compactNumberFormat.format(2_000_000));

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
2 Millionen
ACTUAL -
2 Million

FREQUENCY : always



Comments
URL: https://hg.openjdk.java.net/jdk/jdk/rev/7d732f6e17b2 User: naoto Date: 2019-12-05 21:14:05 +0000
05-12-2019

cldrconverter's current behavior is to adopt the first entry in the range. In this case, CLDR data has multiple entries for 7-digit long pattern, i.e, "Million" for "one", and "Millionen" for "other" (more than one), and the first entry "Million" is used for any 7-digit numbers. Spec of CompactNumberFormat and CLDR converter logic need to be enhanced to deal with these plural situations.
19-04-2019

As per http://www.unicode.org/cldr/charts/latest/supplemental/language_plural_rules.html page, German and Italian use category 'one' and 'other'. As per https://www.unicode.org/cldr/charts/33/by_type/numbers.compact_decimal_formatting.html#717a9789bc2938ae -> '7-digits-long-other' , for 'de' locale 'Millionen' is used. Similarly for 'it' locale , 'milioni' is used. So, I think this is a bug as for 2 million, it should have displayed 2 Millionen for de and 2 milioni for it locales. To reproduce the issue, run the attached test case: JDK-12 - Fail JDk 13-ea + 12 - Fail
19-04-2019