I have just installed jre7 and I\'m surprised to see that my default locale is now en_US. With jre6 it was de_CH.
What is different with jre7? Is the default locale
What about setting your Locale at the start of the program in the following way, depending on java version:
public class LocaleFormatter {
private static Locale locale;
private LocaleFormatter() {
}
public static Locale setDefaultLocale() {
if (locale == null) {
if (!System.getProperty("java.version").startsWith("1.7.")) {
locale = Locale.getDefault();
} else {
try {
Class localeClass = Class.forName("java.util.Locale");
Class categoryClass = Class.forName("java.util.Locale$Category");
Object format = null;
for (Object constant : categoryClass.getEnumConstants()) {
if (constant.toString().equals("FORMAT")) {
format = constant;
}
}
Method method = localeClass.getMethod("getDefault", categoryClass);
locale = (Locale) method.invoke(Locale.getDefault(), format);
Locale.setDefault(locale);
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
}
return locale;
}
}