Search code examples
javalocalizationlocalejava-7java-6

Java Norwegian decimal separator different in Java 6 and 7


The following snippet behaves different in Java 6 than Java 7:

final Locale locale = new Locale("nb", "NO");
System.out.println(locale.getDisplayLanguage()); // Norwegian Bokmål

final DecimalFormatSymbols dfs = new DecimalFormatSymbols(locale);
System.out.println(dfs.getDecimalSeparator());   // Java 6: .
                                                 // Java 7: ,

Why is that? Is this change documented somewhere?


Solution

  • According to JDK 6 and JRE 6 Supported Locales and JDK 7 and JRE 7 Supported Locales, the correct/supported syntax for selecting Norwegian Bokmål is "no"/"NO".

    new Locale("no", "NO") gives the correct result under both Java 6 and Java 7.