I am setting the Locale based on language and region and want to parse a BigDecimal number with this setting. But the issue I am facing is that the grouping separators are different for both OpenJDKs.
Below is the sample code I am trying to execute with OpenJDK 8 and OpenJDK 11.
Locale l = new Locale.Builder().setLanguage("de").setRegion("CH").build();
System.out.println("Locale set to " + Locale.getDefault(Locale.Category.FORMAT));
DecimalFormat nf = (DecimalFormat)NumberFormat.getInstance(Locale.getDefault(Locale.Category.FORMAT));
System.out.println("Grouping Separator: " + nf.getDecimalFormatSymbols().getGroupingSeparator());
Output
OpenJDK 8
---------
Locale set to de_CH
Grouping Separator: '
OpenJDK 11
----------
Locale set to de_CH
Grouping Separator: ’
I need a common parsing method where the grouping separators are returned the same, so that it is easy to design my unit test and it goes through regardless of whether run using java 8 or 11. Please assist.
This is a correct and defined behavior implemented and described as a new feature in Java 11 release notes that refers to JDK-8203868:
Basically, the locale data were updated to Unicode CLDR v33 effective as of JDK 11.