Java 8 和 11 之间相同区域设置的不同分组分隔符
Different grouping separator for same Locale between Java 8 and 11
我正在根据语言和区域设置区域设置,并希望使用此设置解析 BigDecimal 数字。但我面临的问题是两个 OpenJDK 的分组分隔符不同。
下面是我尝试使用 OpenJDK 8 和 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());
输出
OpenJDK 8
---------
Locale set to de_CH
Grouping Separator: '
OpenJDK 11
----------
Locale set to de_CH
Grouping Separator: ’
我需要一种通用的解析方法,其中返回的分组分隔符相同,这样可以轻松设计我的单元测试,并且无论 运行 使用 java 8 还是11. 请协助。
这是 Java 11 release notes that refers to JDK-8203868 中作为新功能实施和描述的正确且定义的行为:
The locale data based on the Unicode Consortium's CLDR (Common Locale Data Registry) has been updated for JDK 11. Localized digits that are in supplementary planes (such as, those in Indian Chakma script) are substituted with ASCII digits until JDK-8204092 is resolved. Medium and short time patterns for Burmese locale have not been upgraded. When JDK-8209175 is resolved, these patterns will be upgraded.
For more detail on CLDR release 33, please refer to http://cldr.unicode.org/index/downloads/cldr-33.
基本上,语言环境数据已更新为 Unicode CLDR v33,自 JDK 11 日起生效。
我正在根据语言和区域设置区域设置,并希望使用此设置解析 BigDecimal 数字。但我面临的问题是两个 OpenJDK 的分组分隔符不同。
下面是我尝试使用 OpenJDK 8 和 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());
输出
OpenJDK 8
---------
Locale set to de_CH
Grouping Separator: '
OpenJDK 11
----------
Locale set to de_CH
Grouping Separator: ’
我需要一种通用的解析方法,其中返回的分组分隔符相同,这样可以轻松设计我的单元测试,并且无论 运行 使用 java 8 还是11. 请协助。
这是 Java 11 release notes that refers to JDK-8203868 中作为新功能实施和描述的正确且定义的行为:
The locale data based on the Unicode Consortium's CLDR (Common Locale Data Registry) has been updated for JDK 11. Localized digits that are in supplementary planes (such as, those in Indian Chakma script) are substituted with ASCII digits until JDK-8204092 is resolved. Medium and short time patterns for Burmese locale have not been upgraded. When JDK-8209175 is resolved, these patterns will be upgraded.
For more detail on CLDR release 33, please refer to http://cldr.unicode.org/index/downloads/cldr-33.
基本上,语言环境数据已更新为 Unicode CLDR v33,自 JDK 11 日起生效。