Java Locale case sensitivity

java, localization

Solution

new Locale("en_US")

is a Locale whose language code is `"en_us"`.

new Locale("en", "US")

is a locale whose language code is `"en"`, and whose country code is `"US"`.

The javadoc says of the single-argument constructor:

Locale

public Locale(String language)

Construct a locale from a language code. This constructor normalizes the language value to lowercase.

Problem

I have the following code to display current locale ``` System.out.println(Locale.getDefault()); System.out.println(new Locale("en_US")); ``` The above gives output as follows ``` en_US en_us ``` How do I construct a Locale instance which gives `en_US` ? EDIT I am asking this because my resources which is `Messages_en_US.properties` is being ignored when I try to set it as default locale if any exception occurs during ``` ResourceBundle.getBundle("Messages", new Locale("en_US")); ```

Original source