Class Locale
java.lang.Object
java.util.Locale
A language, a country and a variant, with the JDK's value semantics:
two locales of the same codes are equal, hash alike and print alike
(en_US). The codes are normalized as the JDK normalizes them -- the
language to lower case, the country to upper case, with an ASCII fold, so
a device set to Turkish cannot turn IT into a dotless it.
This runtime carries no locale data beyond the English names of the
common languages and countries, so the getDisplay* methods answer in
English whatever locale they are asked for, and fall back to the code.
A script and extensions are not kept: getScript is always empty.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final LocaleEnglish in Canada.static final LocaleFrench in Canada.static final LocaleChinese in China; the same locale asSIMPLIFIED_CHINESE.static final LocaleChinese.static final LocaleEnglish.static final LocaleFrench in France.static final LocaleFrench.static final LocaleGerman.static final LocaleGerman in Germany.static final LocaleItalian.static final LocaleItalian in Italy.static final LocaleJapanese in Japan.static final LocaleJapanese.static final LocaleKorean in Korea.static final LocaleKorean.static final LocaleChinese in China; the same locale asSIMPLIFIED_CHINESE.static final LocaleThe root locale: no language, country or variant.static final LocaleChinese as written in China.static final LocaleChinese in Taiwan; the same locale asTRADITIONAL_CHINESE.static final LocaleChinese as written in Taiwan.static final LocaleEnglish in the United Kingdom.static final LocaleEnglish in the United States. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanWhetherobjis a locale of the same language, country and variant.static LocaleforLanguageTag(String languageTag) The locale an IETF BCP 47 language tag names:fr,en-US,zh-Hans-CN.static Locale[]The default locale and the locales this class has constants for.static LocaleThe English name of the country, or its code when this runtime has no name for it.getDisplayCountry(Locale inLocale) AsgetDisplayCountry(): names are in English only.The English name of the language, or its code when this runtime has no name for it.getDisplayLanguage(Locale inLocale) AsgetDisplayLanguage(): names are in English only.English (United States): the language, then the country and the variant in parentheses.getDisplayName(Locale inLocale) AsgetDisplayName(): names are in English only.Always empty: this runtime does not keep a script.getDisplayScript(Locale inLocale) Always empty: this runtime does not keep a script.The variant as it is.getDisplayVariant(Locale inLocale) AsgetDisplayVariant().Always empty: this runtime does not keep a script.The variant, or the empty string.booleanWhether the locale carries extensions; never, here.inthashCode()A hash of the language, country and variant.static Localenew Locale(language).static Localenew Locale(language, country).static Localenew Locale(language, country, variant).static voidsetDefault(Locale l) The locale without extensions, which is the locale itself here.The IETF BCP 47 tag of the locale:en-US,fr, orundfor the root.toString()en_US,fr,en_US_POSIX, or the empty string for the root locale.
-
Field Details
-
ENGLISH
English. -
FRENCH
French. -
GERMAN
German. -
ITALIAN
Italian. -
JAPANESE
Japanese. -
KOREAN
Korean. -
CHINESE
Chinese. -
SIMPLIFIED_CHINESE
Chinese as written in China. -
TRADITIONAL_CHINESE
Chinese as written in Taiwan. -
FRANCE
French in France. -
GERMANY
German in Germany. -
ITALY
Italian in Italy. -
JAPAN
Japanese in Japan. -
KOREA
Korean in Korea. -
CHINA
Chinese in China; the same locale asSIMPLIFIED_CHINESE. -
PRC
Chinese in China; the same locale asSIMPLIFIED_CHINESE. -
TAIWAN
Chinese in Taiwan; the same locale asTRADITIONAL_CHINESE. -
UK
English in the United Kingdom. -
US
English in the United States. -
CANADA
English in Canada. -
CANADA_FRENCH
French in Canada. -
ROOT
The root locale: no language, country or variant.
-
-
Constructor Details
-
Locale
A locale of a language alone. -
Locale
-
Locale
-
-
Method Details
-
of
-
of
-
of
-
getDefault
-
setDefault
-
getLanguage
-
getCountry
-
getVariant
The variant, or the empty string. -
getScript
Always empty: this runtime does not keep a script. -
hasExtensions
public boolean hasExtensions()Whether the locale carries extensions; never, here. -
stripExtensions
The locale without extensions, which is the locale itself here. -
forLanguageTag
The locale an IETF BCP 47 language tag names:fr,en-US,zh-Hans-CN. The first subtag is the language, a four letter subtag after it a script (dropped), the next two letter or three digit subtag the country and the subtags after it, five to eight characters or a digit and three more, the variant. A single character subtag starts the extensions, which are dropped.undand the empty tag are the root locale. -
toLanguageTag
The IETF BCP 47 tag of the locale:en-US,fr, orundfor the root. -
equals
-
hashCode
-
toString
-
getDisplayLanguage
The English name of the language, or its code when this runtime has no name for it. -
getDisplayLanguage
-
getDisplayCountry
The English name of the country, or its code when this runtime has no name for it. -
getDisplayCountry
-
getDisplayVariant
The variant as it is. -
getDisplayVariant
-
getDisplayScript
Always empty: this runtime does not keep a script. -
getDisplayScript
-
getDisplayName
English (United States): the language, then the country and the variant in parentheses. -
getDisplayName
-
getAvailableLocales
The default locale and the locales this class has constants for.
-