Hanif NR
Hanif NR

Reputation: 113

Why detected language result is null in Java

I'm trying to get the language format in Windows, but when I change the display format to English (United States) or English (United Kingdom) the returned value from System.getProperty() is null. For languages other than English, I get the correct result.

I'm using following code:

System.out.println(System.getProperty("user.language.format"));
System.out.println(System.getProperty("user.country.format"));

Upvotes: 4

Views: 371

Answers (1)

user3667171
user3667171

Reputation:

The system properties and any properties in java are loaded at the start of your java application.

so java will load the properties and put them in the hashtable with key value form.

if you do a language format property call, it will take the language of the system and look for it in the hash table.

if you change the properties after running your application it will not find them and will return null.

that's it.

Upvotes: 5

Related Questions