public class LocaleUtils extends LocaleUtils
LocaleUtils class extends Apache's
LocaleUtils to either provide new
functionality or replace existing one.| Constructor and Description |
|---|
LocaleUtils()
Instantiates a new
LocaleUtils object. |
| Modifier and Type | Method and Description |
|---|---|
static Locale |
toLocale(String str)
Converts a string to a Locale.
|
availableLocaleList, availableLocaleSet, countriesByLanguage, isAvailableLocale, languagesByCountry, localeLookupList, localeLookupListpublic static Locale toLocale(String str)
This method takes the string format of a locale and creates the locale
object from it. It also properly supports scripts and extensions. It also
fixes some problems with Apache's version which didn't properly support
locale without a country but with an extension. It also ensures that all
locales that are returned by Locale.getAvailableLocales() can be
properly decoded and returned in such a way that the Locale.equals(java.lang.Object)
method will result to true.
LocaleUtils.toLocale("") = Locale.ROOT
LocaleUtils.toLocale("en") = new Locale("en", "")
LocaleUtils.toLocale("en_GB") = new Locale("en", "GB")
LocaleUtils.toLocale("en_GB_xxx") = new Locale("en", "GB", "xxx") (#)
This method validates the input strictly. The language code must be lowercase. The country code must be uppercase. The separator must be an underscore. The length must be correct.
str - the locale string to convertnull if str is
nullIllegalArgumentException - if the string is an invalid formatCopyright (C) 2015-2015 The Helenus Driver Project Authors.