Package org.primefaces.util
Class LocaleUtils
- java.lang.Object
-
- org.primefaces.util.LocaleUtils
-
public class LocaleUtils extends Object
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static String
calculateLanguage(Locale locale)
Gets ISO 639-1 Language Code from Locale so 'pt_BR' becomes 'pt'.static String
getCurrentLanguage()
Gets ISO 639-1 Language Code from current Locale so 'pt_BR' becomes 'pt'.static Locale
getCurrentLocale()
static Locale
getCurrentLocale(javax.faces.context.FacesContext context)
static String
getDecimalSeparator(javax.faces.context.FacesContext context)
static String
getThousandSeparator(javax.faces.context.FacesContext context)
static Locale
resolveLocale(javax.faces.context.FacesContext context, Object locale, String clientId)
static String
toJavascriptLocale(Locale locale)
Some JS libraries like FullCalendar used by Schedule require the locale for "pt_BR" to be "pt-br".static Locale
toLocale(String str)
Implementation from Apache Commons Lang
-
-
-
Method Detail
-
resolveLocale
public static Locale resolveLocale(javax.faces.context.FacesContext context, Object locale, String clientId)
Gets aLocale
instance by the value of the component attribute "locale" which can be String orLocale
or null.If NULL is passed the view root default locale is used.
- Parameters:
context
- theFacesContext
locale
- given localeclientId
- 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:
- HTML Language Code Reference
-
-