Class LocaleUtils

java.lang.Object
org.primefaces.util.LocaleUtils

public class LocaleUtils extends Object
  • Method Details

    • toLocale

      public static Locale toLocale(String str)
      Implementation from Apache Commons Lang
    • resolveLocale

      public static Locale resolveLocale(javax.faces.context.FacesContext context, Object locale, String clientId)
      Gets a Locale instance by the value of the component attribute "locale" which can be String or Locale or null.

      If NULL is passed the view root default locale is used.

      Parameters:
      context - the FacesContext
      locale - given locale
      clientId - the component clientId
      Returns:
      resolved Locale
    • toJavascriptLocale

      public static String toJavascriptLocale(Locale locale)
      Some JS libraries like FullCalendar used by Schedule require the locale for "pt_BR" to be "pt-br".
      Parameters:
      locale - the Locale to convert
      Returns:
      the Javascript string locale
    • getCurrentLocale

      public static Locale getCurrentLocale(javax.faces.context.FacesContext context)
    • getCurrentLocale

      public static Locale getCurrentLocale()
    • getDecimalSeparator

      public static String getDecimalSeparator(javax.faces.context.FacesContext context)
    • getThousandSeparator

      public static String getThousandSeparator(javax.faces.context.FacesContext context)
    • getCurrentLanguage

      public static String getCurrentLanguage()
      Gets ISO 639-1 Language Code from current Locale so 'pt_BR' becomes 'pt'.
      Returns:
      the ISO 639-1 Language Code
      See Also:
    • calculateLanguage

      public static String calculateLanguage(Locale locale)
      Gets ISO 639-1 Language Code from Locale so 'pt_BR' becomes 'pt'.
      Parameters:
      locale - the Locale to calculate the language for
      Returns:
      the ISO 639-1 Language Code