Package org.xwiki.localization
Class LocaleUtils
- java.lang.Object
-
- org.apache.commons.lang3.LocaleUtils
-
- org.xwiki.localization.LocaleUtils
-
public class LocaleUtils extends org.apache.commons.lang3.LocaleUtils
ExtendsLocaleUtils
with more tools.- Since:
- 5.1RC1
- Version:
- $Id: f41368dd83ab79f2b0d1e9d915aaa75ddf5538fb $
-
-
Constructor Summary
Constructors Constructor Description LocaleUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Locale
getParentLocale(Locale locale)
static Locale
toLocale(String str)
ExtendsLocaleUtils
which returnLocale.ROOT
for an empty string.static Locale
toLocale(String str, Locale fallback)
Same astoLocale(String)
but it never throws an exception.
-
-
-
Method Detail
-
getParentLocale
public static Locale getParentLocale(Locale locale)
- Parameters:
locale
- the locale- Returns:
- the parent locale
-
toLocale
public static Locale toLocale(String str)
ExtendsLocaleUtils
which returnLocale.ROOT
for an empty string.- Parameters:
str
- the locale String to convert, null returns null- Returns:
- a Locale, null if null input
- Throws:
IllegalArgumentException
- if the string is an invalid format- Since:
- 5.2M1
-
toLocale
public static Locale toLocale(String str, Locale fallback)
Same astoLocale(String)
but it never throws an exception. It returns the passed fallback locale in case the given string locale has an invalid format.- Parameters:
str
- the locale string to convert, null returns nullfallback
- the locale to return as fallback in case the given locale string has an invalid format- Returns:
- a Locale, null if null input
- Since:
- 6.0M1
- See Also:
toLocale(String)
-
-