public final class LocaleUtil extends Object
Modifier and Type | Method and Description |
---|---|
static String |
getIndividualLanguageCode(Locale locale)
Returns the lowercase ISO 639 code corresponding to
the individual language of the specified locale.
|
static Locale |
getLocale(String lang)
Returns the Locale corresponding to specified language.
|
static String |
normalizeLang(String lang)
Equivalent to
normalizeLang(lang, null) . |
static String |
normalizeLang(String lang,
String[] parts)
Returns a normalized, possibly simplified, version of
specified language.
|
public static Locale getLocale(String lang)
lang
- specifies the language:
a two-letter ISO language code as defined by ISO-639,
possibly followed by a two-letter ISO Country Code
as defined by ISO-3166. Examples: "en", "en-US", "fr", "fr-CA".NumberFormat.getInstance()
.public static String normalizeLang(String lang)
normalizeLang(lang, null)
.public static String normalizeLang(String lang, String[] parts)
lang
- a language code preferably matching pattern
[a-zA-Z]{1,8}(-[a-zA-Z0-9]{1,8})*parts
- returns lower_case_language in the first element
of this array and upper_case_country or null
in
its second element. May be null
.