Spring Framework
org.springframework.context.i18n

Class LocaleContextHolder

    • Constructor Detail

      • LocaleContextHolder

        public LocaleContextHolder()
    • Method Detail

      • resetLocaleContext

        public static void resetLocaleContext()
        Reset the LocaleContext for the current thread.
      • setLocaleContext

        public static void setLocaleContext(LocaleContext localeContext)
        Associate the given LocaleContext with the current thread, not exposing it as inheritable for child threads.
        Parameters:
        localeContext - the current LocaleContext
      • setLocaleContext

        public static void setLocaleContext(LocaleContext localeContext,
                            boolean inheritable)
        Associate the given LocaleContext with the current thread.
        Parameters:
        localeContext - the current LocaleContext, or null to reset the thread-bound context
        inheritable - whether to expose the LocaleContext as inheritable for child threads (using an InheritableThreadLocal)
      • getLocaleContext

        public static LocaleContext getLocaleContext()
        Return the LocaleContext associated with the current thread, if any.
        Returns:
        the current LocaleContext, or null if none
      • setLocale

        public static void setLocale(Locale locale)
        Associate the given Locale with the current thread.

        Will implicitly create a LocaleContext for the given Locale, not exposing it as inheritable for child threads.

        Parameters:
        locale - the current Locale, or null to reset the thread-bound context
        See Also:
        SimpleLocaleContext.SimpleLocaleContext(java.util.Locale)
      • setLocale

        public static void setLocale(Locale locale,
                     boolean inheritable)
        Associate the given Locale with the current thread.

        Will implicitly create a LocaleContext for the given Locale.

        Parameters:
        locale - the current Locale, or null to reset the thread-bound context
        inheritable - whether to expose the LocaleContext as inheritable for child threads (using an InheritableThreadLocal)
        See Also:
        SimpleLocaleContext.SimpleLocaleContext(java.util.Locale)
      • getLocale

        public static Locale getLocale()
        Return the Locale associated with the current thread, if any, or the system default Locale else.
        Returns:
        the current Locale, or the system default Locale if no specific Locale has been associated with the current thread
        See Also:
        LocaleContext.getLocale(), Locale.getDefault()
Spring Framework