Top Description Inners Fields Constructors Methods
java.util

public final Class Locale

extends Object
implements Cloneable, Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable, java.lang.Cloneable
Imports
java.io.IOException, .ObjectInputStream, .ObjectOutputStream, .ObjectStreamField, .Serializable, java.text.DateFormat, .MessageFormat, java.util.concurrent.ConcurrentHashMap, java.util.function.Function, java.util.spi.LocaleNameProvider, java.util.stream.Stream, jdk.internal.util.ReferencedKeyMap, .StaticProperty, jdk.internal.vm.annotation.Stable, sun.util.locale.BaseLocale, .InternalLocaleBuilder, .LanguageTag, .LocaleExtensions, .LocaleMatcher, .LocaleSyntaxException, .LocaleUtils, .ParseStatus, sun.util.locale.provider.LocaleProviderAdapter, .LocaleResources, .LocaleServiceProviderPool, .TimeZoneNameUtility

A Locale object represents a specific geographical, political, or cultural region. An operation that requires a Locale to perform its task is called locale-sensitive and uses the Locale to tailor information for the user. For example, displaying a number is a locale-sensitive operation— the number should be formatted according to the customs and conventions of the user's native country, region, or culture.

The Locale class implements IETF BCP 47 which is composed of RFC 4647 "Matching of Language Tags" and RFC 5646 "Tags for Identifying Languages" with support for the LDML (UTS#35, "Unicode Locale Data Markup Language") BCP 47-compatible extensions for locale data exchange.

A Locale object logically consists of the fields described below.

language
ISO 639 alpha-2 or alpha-3 language code, or registered language subtags up to 8 alpha letters (for future enhancements). When a language has both an alpha-2 code and an alpha-3 code, the alpha-2 code must be used. You can find a full list of valid language codes in the IANA Language Subtag Registry (search for "Type: language"). The language field is case insensitive, but Locale always canonicalizes to lower case.
Well-formed language values have the form [a-zA-Z]{2,8}. Note that this is not the full BCP47 language production, since it excludes extlang. They are not needed since modern three-letter language codes replace them.
Example: "en" (English), "ja" (Japanese), "kok" (Konkani)
script
ISO 15924 alpha-4 script code. You can find a full list of valid script codes in the IANA Language Subtag Registry (search for "Type: script"). The script field is case insensitive, but Locale always canonicalizes to title case (the first letter is upper case and the rest of the letters are lower case).
Well-formed script values have the form [a-zA-Z]{4}
Example: "Latn" (Latin), "Cyrl" (Cyrillic)
country (region)
ISO 3166 alpha-2 country code or UN M.49 numeric-3 area code. You can find a full list of valid country and region codes in the IANA Language Subtag Registry (search for "Type: region"). The country (region) field is case insensitive, but Locale always canonicalizes to upper case.
Well-formed country/region values have the form [a-zA-Z]{2} | [0-9]{3}
Example: "US" (United States), "FR" (France), "029" (Caribbean)
variant
Any arbitrary value used to indicate a variation of a Locale. Where there are two or more variant values each indicating its own semantics, these values should be ordered by importance, with most important first, separated by underscore('_'). The variant field is case sensitive.
Note: IETF BCP 47 places syntactic restrictions on variant subtags. Also BCP 47 subtags are strictly used to indicate additional variations that define a language or its dialects that are not covered by any combinations of language, script and region subtags. You can find a full list of valid variant codes in the IANA Language Subtag Registry (search for "Type: variant").

However, the variant field in Locale has historically been used for any kind of variation, not just language variations. For example, some supported variants available in Java SE Runtime Environments indicate alternative cultural behaviors such as calendar type or number script. In BCP 47 this kind of information, which does not identify the language, is supported by extension subtags or private use subtags.

Well-formed variant values have the form SUBTAG (('_'|'-') SUBTAG)* where SUBTAG = [0-9][0-9a-zA-Z]{3} | [0-9a-zA-Z]{5,8}. (Note: BCP 47 only uses hyphen ('-') as a delimiter, this is more lenient).
Example: "polyton" (Polytonic Greek), "POSIX"
extensions
A map from single character keys to string values, indicating extensions apart from language identification. The extensions in Locale implement the semantics and syntax of BCP 47 extension subtags and private use subtags. The extensions are case insensitive, but Locale canonicalizes all extension keys and values to lower case. Note that extensions cannot have empty values.
Well-formed keys are single characters from the set [0-9a-zA-Z]. Well-formed values have the form SUBTAG ('-' SUBTAG)* where for the key 'x' SUBTAG = [0-9a-zA-Z]{1,8} and for other keys SUBTAG = [0-9a-zA-Z]{2,8} (that is, 'x' allows single-character subtags).
Example: key="u"/value="ca-japanese" (Japanese Calendar), key="x"/value="java-1-7"

Note

Although BCP 47 requires field values to be registered in the IANA Language Subtag Registry, the Locale class does not provide any validation features. The Builder only checks if an individual field satisfies the syntactic requirement (is well-formed), but does not validate the value itself. See Builder for details.

Unicode locale/language extension

UTS#35, "Unicode Locale Data Markup Language" defines optional attributes and keywords to override or refine the default behavior associated with a locale. A keyword is represented by a pair of key and type. For example, "nu-thai" indicates that Thai local digits (value:"thai") should be used for formatting numbers (key:"nu").

The keywords are mapped to a BCP 47 extension value using the extension key 'u' (UNICODE_LOCALE_EXTENSION). The above example, "nu-thai", becomes the extension "u-nu-thai".

Thus, when a Locale object contains Unicode locale attributes and keywords, getExtension(UNICODE_LOCALE_EXTENSION) will return a String representing this information, for example, "nu-thai". The Locale class also provides getUnicodeLocaleAttributes, getUnicodeLocaleKeys, and getUnicodeLocaleType which allow you to access Unicode locale attributes and key/type pairs directly. When represented as a string, the Unicode Locale Extension lists attributes alphabetically, followed by key/type sequences with keys listed alphabetically (the order of subtags comprising a key's type is fixed when the type is defined)

A well-formed locale key has the form [0-9a-zA-Z]{2}. A well-formed locale type has the form "" | [0-9a-zA-Z]{3,8} ('-' [0-9a-zA-Z]{3,8})* (it can be empty, or a series of subtags 3-8 alphanums in length). A well-formed locale attribute has the form [0-9a-zA-Z]{3,8} (it is a single subtag with the same form as a locale type subtag).

The Unicode locale extension specifies optional behavior in locale-sensitive services. Although the LDML specification defines various keys and values, actual locale-sensitive service implementations in a Java Runtime Environment might not support any particular Unicode locale attributes or key/type pairs.

Obtaining a Locale

There are several ways to obtain a Locale object.

Builder

Using Builder you can construct a Locale object that conforms to BCP 47 syntax.

Factory Methods

The method forLanguageTag obtains a Locale object for a well-formed BCP 47 language tag. The method of(String, String, String) and its overloads obtain a Locale object from given language, country, and/or variant defined above.

Locale Constants

The Locale class provides a number of convenient constants that you can use to obtain Locale objects for commonly used locales. For example, Locale.US is the Locale object for the United States.

Default Locale

The default Locale is provided for any locale-sensitive methods if no Locale is explicitly specified as an argument, such as DateFormat#getInstance(). The default Locale is determined at startup of the Java runtime and established in the following three phases:

  1. The locale-related system properties listed below are established from the host environment. Some system properties (except for user.language) may not have values from the host environment.
    Shows property keys and associated values
    Locale-related System Properties Key Description
    user.language language for the default Locale, such as "en" (English)
    user.script script for the default Locale, such as "Latn" (Latin)
    user.country country for the default Locale, such as "US" (United States)
    user.variant variant for the default Locale, such as "POSIX"
    user.extensions extensions for the default Locale, such as "u-ca-japanese" (Japanese Calendar)
  2. The values of these system properties can be overridden by values designated at startup time. If the overriding value of the user.extensions property is unparsable, it is ignored. The overriding values of other properties are not checked for syntax or validity and are used directly in the default Locale. (Typically, system property values can be provided using the -D command-line option of a launcher. For example, specifying -Duser.extensions=foobarbaz results in a default Locale with no extensions, while specifying -Duser.language=foobarbaz results in a default Locale whose language is "foobarbaz".)
  3. The default Locale instance is constructed from the values of these system properties.

Altering the system property values with System#setProperties(Properties)/ System#setProperty(String, String) has no effect on the default Locale.

Once the default Locale is established, applications can query the default Locale with getDefault() and change it with setDefault(Locale). If the default Locale is changed with setDefault(Locale), the corresponding system properties are not altered. It is not recommended that applications read these system properties and parse or interpret them as their values may be out of date.

There are finer-grained default Locales specific for each Locale.Category. These category specific default Locales can be queried by getDefault(Category), and set by setDefault(Category, Locale). Construction of these category specific default Locales are determined by the corresponding system properties, which consist of the base system properties as listed above, suffixed by either ".display" or ".format" depending on the category. For example, the value of the user.language.display system property will be used in the language part of the default Locale for the Locale.Category#DISPLAY category. In the absence of category specific system properties, the "category-less" system properties are used, such as user.language in the previous example.

Locale Matching

If an application or a system is internationalized and provides localized resources for multiple locales, it sometimes needs to find one or more locales (or language tags) which meet each user's specific preferences. Note that a term "language tag" is used interchangeably with "locale" in this locale matching documentation.

In order to do matching a user's preferred locales to a set of language tags, RFC 4647 Matching of Language Tags defines two mechanisms: filtering and lookup. Filtering is used to get all matching locales, whereas lookup is to choose the best matching locale. Matching is done case-insensitively. These matching mechanisms are described in the following sections.

A user's preference is called a Language Priority List and is expressed as a list of language ranges. There are syntactically two types of language ranges: basic and extended. See Locale.LanguageRange for details.

Filtering

The filtering operation returns all matching language tags. It is defined in RFC 4647 as follows: "In filtering, each language range represents the least specific language tag (that is, the language tag with fewest number of subtags) that is an acceptable match. All of the language tags in the matching set of tags will have an equal or greater number of subtags than the language range. Every non-wildcard subtag in the language range will appear in every one of the matching language tags."

There are two types of filtering: filtering for basic language ranges (called "basic filtering") and filtering for extended language ranges (called "extended filtering"). They may return different results by what kind of language ranges are included in the given Language Priority List. Locale.FilteringMode is a parameter to specify how filtering should be done.

Lookup

The lookup operation returns the best matching language tags. It is defined in RFC 4647 as follows: "By contrast with filtering, each language range represents the most specific tag that is an acceptable match. The first matching tag found, according to the user's priority, is considered the closest match and is the item returned."

For example, if a Language Priority List consists of two language ranges, "zh-Hant-TW" and "en-US", in prioritized order, lookup method progressively searches the language tags below in order to find the best matching language tag.

   1. zh-Hant-TW
   2. zh-Hant
   3. zh
   4. en-US
   5. en
If there is a language tag which matches completely to a language range above, the language tag is returned.

"*" is the special language range, and it is ignored in lookup.

If multiple language tags match as a result of the subtag '*' included in a language range, the first matching language tag returned by an Iterator over a Collection of language tags is treated as the best matching one.

Use of Locale

Once you've obtained a Locale you can query it for information about itself. Use getCountry to get the country (or region) code and getLanguage to get the language code. You can use getDisplayCountry to get the name of the country suitable for displaying to the user. Similarly, you can use getDisplayLanguage to get the name of the language suitable for displaying to the user. Interestingly, the getDisplayXXX methods are themselves locale-sensitive and have two versions: one that uses the default DISPLAY locale and one that uses the locale specified as an argument.

The Java Platform provides a number of classes that perform locale-sensitive operations. For example, the NumberFormat class formats numbers, currency, and percentages in a locale-sensitive manner. Classes such as NumberFormat have several convenience methods for creating a default object of that type. For example, the NumberFormat class provides these three convenience methods for creating a default NumberFormat object:

NumberFormat.getInstance(); NumberFormat.getCurrencyInstance(); NumberFormat.getPercentInstance();
NumberFormat.getInstance();
NumberFormat.getCurrencyInstance();
NumberFormat.getPercentInstance();
Each of these methods has two variants; one with an explicit locale and one without; the latter uses the default FORMAT locale:
NumberFormat.getInstance(myLocale); NumberFormat.getCurrencyInstance(myLocale); NumberFormat.getPercentInstance(myLocale);
NumberFormat.getInstance(myLocale);
NumberFormat.getCurrencyInstance(myLocale);
NumberFormat.getPercentInstance(myLocale);
A Locale is the mechanism for identifying the kind of object (NumberFormat) that you would like to get. The locale is just a mechanism for identifying objects, not a container for the objects themselves.

Compatibility

In order to maintain compatibility, Locale's constructors retain their behavior prior to the Java Runtime Environment version 1.7. The same is largely true for the toString method. Thus Locale objects can continue to be used as they were. In particular, clients who parse the output of toString into language, country, and variant fields can continue to do so (although this is strongly discouraged), although the variant field will have additional information in it if script or extensions are present.

In addition, BCP 47 imposes syntax restrictions that are not imposed by Locale's constructors. This means that conversions between some Locales and BCP 47 language tags cannot be made without losing information. Thus toLanguageTag cannot represent the state of locales whose language, country, or variant do not conform to BCP 47.

Because of these issues, it is recommended that clients migrate away from constructing non-conforming locales and use the forLanguageTag and Locale.Builder APIs instead. Clients desiring a string representation of the complete locale can then always rely on toLanguageTag for this purpose.

Special cases

For compatibility reasons, two non-conforming locales are treated as special cases. These are ja_JP_JP and th_TH_TH. These are ill-formed in BCP 47 since the variants are too short. To ease migration to BCP 47, these are treated specially during construction. These two cases (and only these) cause a constructor to generate an extension, all other values behave exactly as they did prior to Java 7.

Java has used ja_JP_JP to represent Japanese as used in Japan together with the Japanese Imperial calendar. This is now representable using a Unicode locale extension, by specifying the Unicode locale key ca (for "calendar") and type japanese. When the Locale constructor is called with the arguments "ja", "JP", "JP", the extension "u-ca-japanese" is automatically added.

Java has used th_TH_TH to represent Thai as used in Thailand together with Thai digits. This is also now representable using a Unicode locale extension, by specifying the Unicode locale key nu (for "number") and value thai. When the Locale constructor is called with the arguments "th", "TH", "TH", the extension "u-nu-thai" is automatically added.

Serialization

During serialization, writeObject writes all fields to the output stream, including extensions.

During deserialization, readResolve adds extensions as described in Special Cases, only for the two cases th_TH_TH and ja_JP_JP.

Legacy language codes

Locale's constructor has always converted three language codes to their earlier, obsoleted forms: he maps to iw, yi maps to ji, and id maps to in. Since Java SE 17, this is no longer the case. Each language maps to its new form; iw maps to he, ji maps to yi, and in maps to id.

For the backward compatible behavior, the system property java.locale.useOldISOCodes reverts the behavior back to that of before Java SE 17. If the system property is set to true, those three current language codes are mapped to their backward compatible forms. The property is only read at Java runtime startup and subsequent calls to System.setProperty() will have no effect.

The APIs added in 1.7 map between the old and new language codes, maintaining the mapped codes internal to Locale (so that getLanguage and toString reflect the mapped code, which depends on the java.locale.useOldISOCodes system property), but using the new codes in the BCP 47 language tag APIs (so that toLanguageTag reflects the new one). This preserves the equivalence between Locales no matter which code or API is used to construct them. Java's default resource bundle lookup mechanism also implements this mapping, so that resources can be named using either convention, see ResourceBundle.Control.

Three-letter language/country(region) codes

The Locale constructors have always specified that the language and the country param be two characters in length, although in practice they have accepted any length. The specification has now been relaxed to allow language codes of two to eight characters and country (region) codes of two to three characters, and in particular, three-letter language codes and three-digit region codes as specified in the IANA Language Subtag Registry. For compatibility, the implementation still does not impose a length constraint.

Author
Mark Davis
Since
1.1
External Specification
https://www.rfc-editor.org/info/rfc4647, https://www.rfc-editor.org/info/rfc5646
See Also
Builder, ResourceBundle, java.text.Format, java.text.NumberFormat, java.text.Collator

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
Locale.Builder

Builder is used to build instances of Locale from values configured by the setters.

public static enum
Locale.Category

Enum for locale categories.

public static enum
Locale.FilteringMode

This enum provides constants to select a filtering mode for locale matching.

public static enum
Locale.IsoCountryCode

Enum for specifying the type defined in ISO 3166.

public static class
Locale.LanguageRange

This class expresses a Language Range defined in RFC 4647 Matching of Language Tags.

private static class
private static class
Locale.LocaleNameGetter

Obtains a localized locale names from a LocaleNameProvider implementation.

Field Summary

Modifier and TypeField and Description
private transient BaseLocale
public static final Locale
CANADA

Useful constant for country.

public static final Locale
CANADA_FRENCH

Useful constant for country.

public static final Locale
CHINA

Useful constant for country.

public static final Locale
CHINESE

Useful constant for language.

private static final Map<BaseLocale, Locale>
private static volatile Locale
private static volatile Locale
private static volatile Locale
private static final int
private static final int
DISPLAY_LANGUAGE

Display types for retrieving localized names from the name providers.

private static final int
private static final int
private static final int
private static final int
public static final Locale
ENGLISH

Useful constant for language.

public static final Locale
FRANCE

Useful constant for country.

public static final Locale
FRENCH

Useful constant for language.

public static final Locale
GERMAN

Useful constant for language.

public static final Locale
GERMANY

Useful constant for country.

private transient int
hashCodeValue

Calculated hashcode

private static volatile String[]
private static volatile String[]
public static final Locale
ITALIAN

Useful constant for language.

public static final Locale
ITALY

Useful constant for country.

public static final Locale
JAPAN

Useful constant for country.

public static final Locale
JAPANESE

Useful constant for language.

public static final Locale
KOREA

Useful constant for country.

public static final Locale
KOREAN

Useful constant for language.

private transient volatile String
private static final ReferencedKeyMap<Object, Locale>
private static final Function<Object, Locale>
private transient LocaleExtensions
public static final Locale
PRC

Useful constant for country.

public static final char
PRIVATE_USE_EXTENSION

The key for the private use extension ('x').

public static final Locale
ROOT

Useful constant for the root locale.

private static final ObjectStreamField[]
pack-priv static final long
serialVersionUID

serialization ID

public static final Locale
SIMPLIFIED_CHINESE

Useful constant for language.

public static final Locale
TAIWAN

Useful constant for country.

public static final Locale
TRADITIONAL_CHINESE

Useful constant for language.

public static final Locale
UK

Useful constant for country.

public static final char
UNICODE_LOCALE_EXTENSION

The key for Unicode locale extension ('u').

public static final Locale
US

Useful constant for country.

Constructor Summary

AccessConstructor and Description
private
Locale(BaseLocale baseLocale, LocaleExtensions extensions)

Private constructor used by getInstance method

public
Locale(String
An ISO 639 alpha-2 or alpha-3 language code, or a language subtag up to 8 characters in length. See the Locale class description about valid language values.
language
,
String
An ISO 3166 alpha-2 country code or a UN M.49 numeric-3 area code. See the Locale class description about valid country values.
country
,
String
Any arbitrary value used to indicate a variation of a Locale. See the Locale class description for the details.
variant
)
Deprecated since 19. Locale constructors have been deprecated. See Obtaining a Locale for other options.

Construct a locale from language, country and variant.

public
Locale(String
An ISO 639 alpha-2 or alpha-3 language code, or a language subtag up to 8 characters in length. See the Locale class description about valid language values.
language
,
String
An ISO 3166 alpha-2 country code or a UN M.49 numeric-3 area code. See the Locale class description about valid country values.
country
)
Deprecated since 19. Locale constructors have been deprecated. See Obtaining a Locale for other options.

Construct a locale from language and country.

public
Locale(String
An ISO 639 alpha-2 or alpha-3 language code, or a language subtag up to 8 characters in length. See the Locale class description about valid language values.
language
)
Deprecated since 19. Locale constructors have been deprecated. See Obtaining a Locale for other options.

Construct a locale from a language code.

Method Summary

Modifier and TypeMethod and Description
public static Stream<Locale>

Returns:

a stream of installed locales
availableLocales
()

Returns a stream of installed locales.

public static String

Returns:

a case folded IETF BCP 47 language tag
caseFoldLanguageTag
(String
the IETF BCP 47 language tag.
languageTag
)

Returns a case folded IETF BCP 47 language tag.

public Object
clone()

Overrides java.lang.Object.clone.

Overrides Cloneable.

private static String
private static Locale
createConstant(byte baseType)

This method must be called only for creating the Locale.* constants due to making shortcuts.

public boolean

Returns:

true if this Locale is equal to the specified object.
equals
(Object
the reference object with which to compare.
obj
)

Overrides java.lang.Object.equals.

Returns true if this Locale is equal to another object.

public static List<Locale>

Returns:

a list of Locale instances for matching language tags sorted in descending order based on priority or weight, or an empty list if nothing matches. The list is modifiable.
filter
(List<Locale.LanguageRange>
user's Language Priority List in which each language tag is sorted in descending order based on priority or weight
priorityList
,
Collection<Locale>
Locale instances used for matching
locales
,
Locale.FilteringMode
filtering mode
mode
)

Returns a list of matching Locale instances using the filtering mechanism defined in RFC 4647.

public static List<Locale>

Returns:

a list of Locale instances for matching language tags sorted in descending order based on priority or weight, or an empty list if nothing matches. The list is modifiable.
filter
(List<Locale.LanguageRange>
user's Language Priority List in which each language tag is sorted in descending order based on priority or weight
priorityList
,
Collection<Locale>
Locale instances used for matching
locales
)

Returns a list of matching Locale instances using the filtering mechanism defined in RFC 4647.

public static List<String>

Returns:

a list of matching language tags sorted in descending order based on priority or weight, or an empty list if nothing matches. The list is modifiable.
filterTags
(List<Locale.LanguageRange>
user's Language Priority List in which each language tag is sorted in descending order based on priority or weight
priorityList
,
Collection<String>
language tags
tags
,
Locale.FilteringMode
filtering mode
mode
)

Returns a list of matching languages tags using the basic filtering mechanism defined in RFC 4647.

public static List<String>

Returns:

a list of matching language tags sorted in descending order based on priority or weight, or an empty list if nothing matches. The list is modifiable.
filterTags
(List<Locale.LanguageRange>
user's Language Priority List in which each language tag is sorted in descending order based on priority or weight
priorityList
,
Collection<String>
language tags
tags
)

Returns a list of matching languages tags using the basic filtering mechanism defined in RFC 4647.

public static Locale

Returns:

The locale that best represents the language tag.
forLanguageTag
(String
the language tag
languageTag
)

Returns a locale for the specified IETF BCP 47 language tag string.

private static String

Returns:

a string representing the list.
formatList
(String[]
the list of strings to be formatted. and formatting them into a list.
stringList
,
String
should take 2 arguments for reduction
pattern
)

Format a list using given pattern strings.

public static Locale[]

Returns:

an array of installed locales
getAvailableLocales
()

Returns an array of installed locales.

pack-priv BaseLocale

Returns:

base locale of this Locale
getBaseLocale
()

Package locale method returning the Locale's BaseLocale, used by ResourceBundle

private static LocaleExtensions
getCompatibilityExtensions(String language, String script, String country, String variant)

public String

Returns:

The country/region code, or the empty string if none is defined.
getCountry
()

Returns the country/region code for this locale, which should either be the empty string, an uppercase ISO 3166 2-letter code, or a UN M.49 3-digit code.

public static Locale

Returns:

the default locale for this instance of the Java Virtual Machine
getDefault
()

Gets the current value of the default locale for this instance of the Java Virtual Machine.

public static Locale

Returns:

the default locale for the specified Category for this instance of the Java Virtual Machine
getDefault
(Locale.Category
the specified category to get the default locale
category
)

Gets the current value of the default locale for the specified Category for this instance of the Java Virtual Machine.

private static Optional<LocaleExtensions>
getDefaultExtensions(String extensionsProp)

public final String

Returns:

The name of the country appropriate to the locale.
getDisplayCountry
()

Returns a name for the locale's country that is appropriate for display to the user.

public String

Returns:

The name of the country appropriate to the given locale.
getDisplayCountry
(Locale
The locale for which to retrieve the display country.
inLocale
)

Returns a name for the locale's country that is appropriate for display to the user.

private String
public final String

Returns:

The name of the display language.
getDisplayLanguage
()

Returns a name for the locale's language that is appropriate for display to the user.

public String

Returns:

The name of the display language appropriate to the given locale.
getDisplayLanguage
(Locale
The locale for which to retrieve the display language.
inLocale
)

Returns a name for the locale's language that is appropriate for display to the user.

private static synchronized Locale
public final String

Returns:

The name of the locale appropriate to display.
getDisplayName
()

Returns a name for the locale that is appropriate for display to the user.

public String

Returns:

The name of the locale appropriate to display.
getDisplayName
(Locale
The locale for which to retrieve the display name.
inLocale
)

Returns a name for the locale that is appropriate for display to the user.

public String

Returns:

the display name of the script code for the current default DISPLAY locale
getDisplayScript
()

Returns a name for the locale's script that is appropriate for display to the user.

public String

Returns:

the display name of the script code for the current default DISPLAY locale
getDisplayScript
(Locale
The locale for which to retrieve the display script.
inLocale
)

Returns a name for the locale's script that is appropriate for display to the user.

private String
getDisplayString(String code, String cat, Locale inLocale, int type)

public final String

Returns:

The name of the display variant code appropriate to the locale.
getDisplayVariant
()

Returns a name for the locale's variant code that is appropriate for display to the user.

public String

Returns:

The name of the display variant code appropriate to the given locale.
getDisplayVariant
(Locale
The locale for which to retrieve the display variant code.
inLocale
)

Returns a name for the locale's variant code that is appropriate for display to the user.

private String[]

Returns:

an array of display names, possible of zero length.
getDisplayVariantArray
(Locale
The locale for which to retrieve the display variant.
inLocale
)

Return an array of the display names of the variant.

public String

Returns:

The extension, or null if this locale defines no extension for the specified key.
getExtension
(char
the extension key
key
)

Returns the extension (or private use) value associated with the specified key, or null if there is no extension associated with the key.

public Set<Character>

Returns:

The set of extension keys, or the empty set if this locale has no extensions.
getExtensionKeys
()

Returns the set of extension keys associated with this locale, or the empty set if it has no extensions.

private static synchronized Locale
pack-priv static Locale

Returns:

the Locale instance requested
getInstance
(String
lowercase 2 to 8 language code.
language
,
String
uppercase two-letter ISO-3166 code and numeric-3 UN M.49 area code.
country
,
String
vendor and browser specific code. See class description.
variant
)

Returns a Locale constructed from the given language, country and variant.

pack-priv static Locale
getInstance(String language, String script, String country, String variant, LocaleExtensions extensions)

pack-priv static Locale
private static String[]
private static String
getISO3Code(String iso2Code, String table)

public String

Returns:

a three-letter abbreviation of this locale's country
getISO3Country
()

Returns a three-letter abbreviation of this locale's country.

public String

Returns:

a three-letter abbreviation of this locale's language
getISO3Language
()

Returns a three-letter abbreviation of this locale's language.

public static String[]

Returns:

An array of ISO 3166 two-letter country codes.
getISOCountries
()

Returns a list of all 2-letter country codes defined in ISO 3166.

public static Set<String>

Returns:

a Set of ISO3166 country codes for the specified type
getISOCountries
(Locale.IsoCountryCode
Locale.IsoCountryCode specified ISO code type.
type
)

Returns a Set of ISO3166 country codes for the specified type.

public static String[]

Returns:

An array of ISO 639 two-letter language codes.
getISOLanguages
()

Returns a list of all 2-letter language codes defined in ISO 639.

public String

Returns:

The language code, or the empty string if none is defined.
getLanguage
()

Returns the language code of this Locale.

pack-priv LocaleExtensions

Returns:

locale extensions of this Locale, or null if no extensions are defined
getLocaleExtensions
()

Package private method returning the Locale's LocaleExtensions, used by ResourceBundle.

public String

Returns:

The script code, or the empty string if none is defined.
getScript
()

Returns the script for this locale, which should either be the empty string or an ISO 15924 4-letter script code.

public Set<String>

Returns:

The set of attributes.
getUnicodeLocaleAttributes
()

Returns the set of unicode locale attributes associated with this locale, or the empty set if it has no attributes.

public Set<String>

Returns:

The set of Unicode locale keys, or the empty set if this locale has no Unicode locale keywords.
getUnicodeLocaleKeys
()

Returns the set of Unicode locale keys defined by this locale, or the empty set if this locale has none.

public String

Returns:

The Unicode locale type associated with the key, or null if the locale does not define the key.
getUnicodeLocaleType
(String
the Unicode locale key
key
)

Returns the Unicode locale type associated with the specified Unicode locale key for this locale.

public String

Returns:

The variant code, or the empty string if none is defined.
getVariant
()

Returns the variant code for this locale.

public boolean

Returns:

true if this Locale has any extensions
hasExtensions
()

Returns true if this Locale has any extensions.

public int
hashCode()

Overrides java.lang.Object.hashCode.

Override hashCode.

private static Locale
private static Locale
private static boolean
public static Locale

Returns:

the best matching Locale instance chosen based on priority or weight, or null if nothing matches.
lookup
(List<Locale.LanguageRange>
user's Language Priority List in which each language tag is sorted in descending order based on priority or weight
priorityList
,
Collection<Locale>
Locale instances used for matching
locales
)

Returns a Locale instance for the best-matching language tag using the lookup mechanism defined in RFC 4647.

public static String

Returns:

the best matching language tag chosen based on priority or weight, or null if nothing matches.
lookupTag
(List<Locale.LanguageRange>
user's Language Priority List in which each language tag is sorted in descending order based on priority or weight
priorityList
,
Collection<String>
language tags used for matching
tags
)

Returns the best-matching language tag using the lookup mechanism defined in RFC 4647.

public static Locale

Returns:

A Locale object
of
(String
A language code. See the Locale class description of language values.
language
,
String
A country code. See the Locale class description of country values.
country
,
String
Any arbitrary value used to indicate a variation of a Locale. See the Locale class description of variant values.
variant
)

Obtains a locale from language, country and variant.

public static Locale

Returns:

A Locale object
of
(String
A language code. See the Locale class description of language values.
language
,
String
A country code. See the Locale class description of country values.
country
)

Obtains a locale from language and country.

public static Locale

Returns:

A Locale object
of
(String
A language code. See the Locale class description of language values.
language
)

Obtains a locale from a language code.

private void
readObject(ObjectInputStream
the ObjectInputStream to read
in
)

Deserializes this Locale.

private Object

Returns:

an instance of Locale equivalent to the deserialized Locale.
readResolve
()

Returns a cached Locale instance equivalent to the deserialized Locale.

public static synchronized void
setDefault(Locale
the new default locale
newLocale
)

Sets the default locale for this instance of the Java Virtual Machine.

public static synchronized void
setDefault(Locale.Category
the specified category to set the default locale
category
,
Locale
the new default locale
newLocale
)

Sets the default locale for the specified Category for this instance of the Java Virtual Machine.

public Locale

Returns:

a copy of this Locale with no extensions, or this if this has no extensions
stripExtensions
()

Returns a copy of this Locale with no extensions.

public String

Returns:

a BCP47 language tag representing the locale
toLanguageTag
()

Returns a well-formed IETF BCP 47 language tag representing this locale.

public final String

Returns:

A string representation of the Locale, for debugging.
toString
()

Overrides java.lang.Object.toString.

Returns a string representation of this Locale object, consisting of language, country, variant, script, and extensions as below:

language + "_" + country + "_" + (variant + "_#" | "#") + script + "_" + extensions
private void
writeObject(ObjectOutputStream
the ObjectOutputStream to write
out
)

Serializes this Locale to the specified ObjectOutputStream.

Inherited from java.lang.Object:
finalizegetClassnotifynotifyAllwaitwaitwait