Class LocaleUtils


  • public class LocaleUtils
    extends java.lang.Object
    Utility methods for getting the locale from a request.
    Author:
    Stuart Douglas
    • Constructor Summary

      Constructors 
      Constructor Description
      LocaleUtils()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.util.Locale getLocaleFromString​(java.lang.String localeString)  
      static java.util.List<java.util.Locale> getLocalesFromHeader​(java.lang.String acceptLanguage)
      Parse a header string and return the list of locales that were found.
      static java.util.List<java.util.Locale> getLocalesFromHeader​(java.util.List<java.lang.String> acceptLanguage)
      Parse a header string and return the list of locales that were found.
      • Methods inherited from class java.lang.Object

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

      • LocaleUtils

        public LocaleUtils()
    • Method Detail

      • getLocaleFromString

        public static java.util.Locale getLocaleFromString​(java.lang.String localeString)
      • getLocalesFromHeader

        public static java.util.List<java.util.Locale> getLocalesFromHeader​(java.lang.String acceptLanguage)
        Parse a header string and return the list of locales that were found. If the header is empty or null then an empty list will be returned.
        Parameters:
        acceptLanguage - The Accept-Language header
        Returns:
        The list of locales, in order of preference
      • getLocalesFromHeader

        public static java.util.List<java.util.Locale> getLocalesFromHeader​(java.util.List<java.lang.String> acceptLanguage)
        Parse a header string and return the list of locales that were found. If the header is empty or null then an empty list will be returned.
        Parameters:
        acceptLanguage - The Accept-Language header
        Returns:
        The list of locales, in order of preference