Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java 7 default locale

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 no more the one of the Operating System? (btw, I'm using Windows7)

Thx for your answer.

Edit: I have seen the Locale for Category.FORMAT is the "old" one (de_CH). The Locale for Category.DISPLAY takes the language from the language of the OS (in Windows this is done in Control Panel > Region and Language > Keyboard and Languages > Display Language) and the contry from...?

What seems to be different is the property "user.country". With Java6 I get "CH" and with Java7 I get "US".

like image 983
Neo Avatar asked Aug 18 '11 13:08

Neo


People also ask

What is the default locale?

The default locale determines the format. The number may be a primitive (such as int or double ) or a wrapper object (such as Integer or Double ). The language is english and the country is Great Britain. Locales specify both language and country.

How does Java determine default locale?

That is, the JVM determines the default locale from the host environment. The host environment's locale is determined by the host operating system and the user preferences established on that system.

How do I change the default locale in Java?

In Java, we can use Locale. setDefault() to change the JVM default locale. Alternatively, in the command line, we can configure the user. country and user.

Where is my Java locale?

To get equivalent information in Java, use Locale. getDefault() to get the Locale that Java is using, and use methods on the Locale object such as getCountry() , getLanguage() to get details. The information is available using ISO codes and as human readable/displayable names.


1 Answers

This is as designed. Java 7 has changed the way Locale.getDefault() works. A defect has been entered with Oracle, but they basically said this is As Designed.

To sum up, you must modify the Display Language of the OS. Modifying the Region Format only is no longer sufficient.

Read the bug report here: Locale.getDefault() returns wrong Locale for Java SE 7

like image 63
dream_team Avatar answered Sep 21 '22 17:09

dream_team