Java Reference
In-Depth Information
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 Cay-
man 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 unspeci-
fied, use
""
, an empty stringnot
null
.
public
Locale(String language, String country)
Equivalent to
Locale(language,country, "")
.
public
Locale(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 coun-
try 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 convenien-
ces and have no special privileges compared to any
Locale
object you
may create.
The static method
setDefault
changes the default locale. The default loc-
ale 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.