Class LocaleUtils


  • public final class LocaleUtils
    extends java.lang.Object
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.util.List<java.util.Locale> getAvailableLocales​(boolean andRegionalVariants)
      Returns the available locales, sorted.
      static java.util.Optional<java.util.Locale> parseLocale​(java.lang.String locale)
      Attempt to parse the given string into a locale - first, as a Java formatted locale, using LocaleUtils.toLocale(String) - but if that fails, then by parsing it as a language tag.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • getAvailableLocales

        public static java.util.List<java.util.Locale> getAvailableLocales​(boolean andRegionalVariants)
        Returns the available locales, sorted. If andRegionalVariants is true, they will be included, otherwise only the base languages will be returned.
      • parseLocale

        public static java.util.Optional<java.util.Locale> parseLocale​(@Nullable
                                                                       java.lang.String locale)
        Attempt to parse the given string into a locale - first, as a Java formatted locale, using LocaleUtils.toLocale(String) - but if that fails, then by parsing it as a language tag. Will attempt to return an empty optional, rather than an invalid locale.