Calendar now = Calendar.getInstance();
The Calendar class's getInstance method looks up the default locale to configure the calendar object it
returns. When you write your own locale-sensitive classes, you get the default locale from the static
getdefault method of the Locale class.
If you write code that lets a user select a locale, you may need to create Locale objects. There are three
constructors:
publicLocale(String language, String country, String variant)
Creates a Locale object that represents the given language and country,
where language is the two-letter ISO 639 code for the language (such as
"et" for Estonian) and country is the two-letter ISO 3166 code for the
country (such as "KY" for Cayman Islands). "Further Reading" on page 755
lists references for these codes. The variant can specify anything, such as
an operating environment (such as "POSIX" or "MAC") or company or era.
If you specify more than one variant, separate the two with an underscore. To
leave any part of the locale unspecified, use "", an empty stringnot null.
publicLocale(String language, String country)
Equivalent to Locale(language,country,"").
publicLocale(String language)
Equivalent to Locale(language,"","").
The language and country can be in any case, but they will always be translated to lowercase for the language
and uppercase for the country to conform to the governing standards. The variant is translated into uppercase.
The Locale class defines static Locale objects for several well-known locales, such as CANADA_FRENCH
and KOREA for countries, and KOREAN and TRADITIONAL_CHINESE for languages. These objects are
simply conveniences and have no special privileges compared to any Locale object you may create.
The static method setDefault changes the default locale. The default locale is shared state and should
always reflect the user's preference. If you have code that must operate in a different locale, you can specify
that locale to locale-sensitive classes either as an argument when you get resources or on specific operations.
You should rarely need to change the default locale.
Locale provides methods for getting the parts of the locale description. The methods getCountry,
getLanguage, and getVariant return the values defined during construction. These are terse codes that
most users will not know. These methods have "display" variantsgetdisplayCountry,
getdisplayLanguage, and getdisplayVariantthat return human-readable versions of the values.
The method getdisplayName returns a human-readable summary of the entire locale description, and
toString returns the terse equivalent, using underscores to separate the parts. These "display" methods
return values that are localized according to the default locale.
You can optionally provide a Locale argument to any of the "display" methods to get a description of the
given locale under the provided locale. For example, if we print the value of
Locale.ITALY.getDisplayCountry(Locale.FRANCE)