Client and backend. This class is shared: the same code is compiled into your app and into your server, so everything on this page works in both.
public class Locale
- Object
- 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.
Fields
Constructors
public Locale(String language) | A locale of a language alone. |
public Locale(String language, String country) | A locale of a language and a country. |
public Locale(String language, String country, String variant) | A locale of a language, a country and a variant. |
Methods
Inherited methods
Field details
ENGLISH
public static final Locale ENGLISHFRENCH
public static final Locale FRENCHGERMAN
public static final Locale GERMANITALIAN
public static final Locale ITALIANJAPANESE
public static final Locale JAPANESEKOREAN
public static final Locale KOREANCHINESE
public static final Locale CHINESESIMPLIFIED_CHINESE
public static final Locale SIMPLIFIED_CHINESETRADITIONAL_CHINESE
public static final Locale TRADITIONAL_CHINESEFRANCE
public static final Locale FRANCEGERMANY
public static final Locale GERMANYITALY
public static final Locale ITALYJAPAN
public static final Locale JAPANKOREA
public static final Locale KOREACHINA
public static final Locale CHINASIMPLIFIED_CHINESE.PRC
public static final Locale PRCSIMPLIFIED_CHINESE.TAIWAN
public static final Locale TAIWANTRADITIONAL_CHINESE.UK
public static final Locale UKUS
public static final Locale USCANADA
public static final Locale CANADACANADA_FRENCH
public static final Locale CANADA_FRENCHROOT
public static final Locale ROOTConstructor details
Locale
public Locale(String language)Locale
public Locale(String language, String country)Locale
public Locale(String language, String country, String variant)Throws
NullPointerException- if any of them is null
Method details
of
public static Locale of(String language)new Locale(language).of
public static Locale of(String language, String country)new Locale(language, country).of
public static Locale of(String language, String country, String variant)new Locale(language, country, variant).getDefault
public static Locale getDefault()setDefault
public static void setDefault(Locale l)getLanguage
public String getLanguage()getCountry
public String getCountry()getVariant
public String getVariant()getScript
public String getScript()hasExtensions
public boolean hasExtensions()stripExtensions
public Locale stripExtensions()forLanguageTag
public static Locale forLanguageTag(String languageTag)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. und and the empty tag are the
root locale.toLanguageTag
public String toLanguageTag()en-US, fr, or und for the
root.equals
public boolean equals(Object obj)obj is a locale of the same language, country and variant.hashCode
public int hashCode()toString
public String toString()en_US, fr, en_US_POSIX, or the empty string for the root locale.getDisplayLanguage
public String getDisplayLanguage()getDisplayLanguage
public String getDisplayLanguage(Locale inLocale)getDisplayLanguage(): names are in English only.getDisplayCountry
public String getDisplayCountry()getDisplayCountry
public String getDisplayCountry(Locale inLocale)getDisplayCountry(): names are in English only.getDisplayVariant
public String getDisplayVariant()getDisplayVariant
public String getDisplayVariant(Locale inLocale)getDisplayVariant().getDisplayScript
public String getDisplayScript()getDisplayScript
public String getDisplayScript(Locale inLocale)getDisplayName
public String getDisplayName()English (United States): the language, then the country and the
variant in parentheses.getDisplayName
public String getDisplayName(Locale inLocale)getDisplayName(): names are in English only.getAvailableLocales
public static Locale[] getAvailableLocales()