Package de.xima.fc.common.utils
Class XLocaleUtils
- java.lang.Object
-
- de.xima.fc.common.utils.XLocaleUtils
-
public final class XLocaleUtils extends Object
Utility class for locale related operations.- Since:
- 8.2.0
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
XLocaleUtils.LocaleMatcher
A predicate on a locale.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Comparator<Locale>
comparingLocaleByDisplayName(Locale locale)
Compares two locales by their display name in the given locale, ignoring case.static String
getDisplayName(Locale locale, Locale viewLocale)
Gets the display name of a locale in the given view locale, or the default display name if the view locale is null.static String
localeBaseLanguage(Locale locale)
Gets the base language of a locale, returning an empty string if the locale is null.static Locale
toBaseLocale(Locale locale)
Converts a locale to a base locale, stripping off the country and variant.
-
-
-
Method Detail
-
comparingLocaleByDisplayName
public static Comparator<Locale> comparingLocaleByDisplayName(Locale locale)
Compares two locales by their display name in the given locale, ignoring case.- Parameters:
locale
- The locale to use for obtaining each locale's display name.- Returns:
- A comparator that compares two locales by their display name in the given locale.
-
getDisplayName
public static String getDisplayName(Locale locale, Locale viewLocale)
Gets the display name of a locale in the given view locale, or the default display name if the view locale is null.- Parameters:
locale
- The locale to get the display name of.viewLocale
- The locale to use for obtaining the display name.- Returns:
- The display name of the locale.
-
localeBaseLanguage
public static String localeBaseLanguage(Locale locale)
Gets the base language of a locale, returning an empty string if the locale is null.- Parameters:
locale
- The locale to get the base language of.- Returns:
- The base language of the locale.
-
-