inheritable flag is set to true.
Used as a central holder for the current Locale in Spring, wherever necessary: for example, in MessageSourceAccessor. DispatcherServlet automatically exposes its current Locale here. Other applications can expose theirs too, to make classes like MessageSourceAccessor automatically use that Locale.
LocaleContext, org.springframework.context.support.MessageSourceAccessor , org.springframework.web.servlet.DispatcherServlet
| Modifier and Type | Field and Description |
|---|---|
| private static Locale | |
| private static TimeZone | |
| private static final ThreadLocal | |
| private static final ThreadLocal |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public static Locale | Returns: the current Locale, or the system default Locale if no specific Locale has been associated with the current threadReturn the Locale associated with the current thread, if any, or the system default Locale otherwise. |
| public static Locale | Returns: the current Locale, or the system default Locale if no specific Locale has been associated with the current threadthe user-level locale context to check localeContext)Return the Locale associated with the given user context, if any, or the system default Locale otherwise. |
| public static LocaleContext | Returns: the current LocaleContext, ornull if noneReturn the LocaleContext associated with the current thread, if any. |
| public static TimeZone | Returns: the current TimeZone, or the system default TimeZone if no specific TimeZone has been associated with the current threadReturn the TimeZone associated with the current thread, if any, or the system default TimeZone otherwise. |
| public static TimeZone | Returns: the current TimeZone, or the system default TimeZone if no specific TimeZone has been associated with the current threadthe user-level locale context to check localeContext)Return the TimeZone associated with the given user context, if any, or the system default TimeZone otherwise. |
| public static void | |
| public static void | setDefaultLocale(Locale
the default locale (or locale)null for none,
letting lookups fall back to Locale#getDefault())Set a shared default locale at the framework level, as an alternative to the JVM-wide default locale. |
| public static void | setDefaultTimeZone(TimeZone
the default time zone (or timeZone)null for none,
letting lookups fall back to TimeZone#getDefault())Set a shared default time zone at the framework level, as an alternative to the JVM-wide default time zone. |
| public static void | |
| public static void | setLocale(Locale
the current Locale, or locale, boolean null to reset
the locale part of thread-bound contextwhether to expose the LocaleContext as inheritable
for child threads (using an inheritable)InheritableThreadLocal)Associate the given Locale with the current thread, preserving any TimeZone that may have been set already. |
| public static void | setLocaleContext(LocaleContext
the current LocaleContext,
or localeContext)null to reset the thread-bound contextAssociate the given LocaleContext with the current thread, not exposing it as inheritable for child threads. |
| public static void | setLocaleContext(LocaleContext
the current LocaleContext,
or localeContext, boolean null to reset the thread-bound contextwhether to expose the LocaleContext as inheritable
for child threads (using an inheritable)InheritableThreadLocal)Associate the given LocaleContext with the current thread. |
| public static void | setTimeZone(TimeZone
the current TimeZone, or timeZone)null to reset
the time zone part of the thread-bound contextAssociate the given TimeZone with the current thread, preserving any Locale that may have been set already. |
| public static void | setTimeZone(TimeZone
the current TimeZone, or timeZone, boolean null to reset
the time zone part of the thread-bound contextwhether to expose the LocaleContext as inheritable
for child threads (using an inheritable)InheritableThreadLocal)Associate the given TimeZone with the current thread, preserving any Locale that may have been set already. |
| defaultLocale | back to summary |
|---|---|
| private static Locale defaultLocale
| |
| defaultTimeZone | back to summary |
|---|---|
| private static TimeZone defaultTimeZone
| |
| inheritableLocaleContextHolder | back to summary |
|---|---|
| private static final ThreadLocal<LocaleContext> inheritableLocaleContextHolder | |
| localeContextHolder | back to summary |
|---|---|
| private static final ThreadLocal<LocaleContext> localeContextHolder | |
| LocaleContextHolder | back to summary |
|---|---|
| private LocaleContextHolder() | |
| getLocale | back to summary |
|---|---|
| public static Locale getLocale() Return the Locale associated with the current thread, if any,
or the system default Locale otherwise. This is effectively a
replacement for Note This method has a fallback to the shared default Locale,
either at the framework level or at the JVM-wide system level.
If you'd like to check for the raw LocaleContext content
(which may indicate no specific locale through
| |
| getLocale | back to summary |
|---|---|
| public static Locale getLocale(LocaleContext localeContext) Return the Locale associated with the given user context, if any,
or the system default Locale otherwise. This is effectively a
replacement for
| |
| getLocaleContext | back to summary |
|---|---|
| public static LocaleContext getLocaleContext() Return the LocaleContext associated with the current thread, if any.
| |
| getTimeZone | back to summary |
|---|---|
| public static TimeZone getTimeZone() Return the TimeZone associated with the current thread, if any,
or the system default TimeZone otherwise. This is effectively a
replacement for Note This method has a fallback to the shared default TimeZone,
either at the framework level or at the JVM-wide system level.
If you'd like to check for the raw LocaleContext content
(which may indicate no specific time zone through
| |
| getTimeZone | back to summary |
|---|---|
| public static TimeZone getTimeZone(LocaleContext localeContext) Return the TimeZone associated with the given user context, if any,
or the system default TimeZone otherwise. This is effectively a
replacement for
| |
| resetLocaleContext | back to summary |
|---|---|
| public static void resetLocaleContext() Reset the LocaleContext for the current thread. | |
| setDefaultLocale | back to summary |
|---|---|
| public static void setDefaultLocale(Locale locale) Set a shared default locale at the framework level, as an alternative to the JVM-wide default locale. Note This can be useful to set an application-level default locale which differs from the JVM-wide default locale. However, this requires each such application to operate against locally deployed Spring Framework jars. Do not deploy Spring as a shared library at the server level in such a scenario!
| |
| setDefaultTimeZone | back to summary |
|---|---|
| public static void setDefaultTimeZone(TimeZone timeZone) Set a shared default time zone at the framework level, as an alternative to the JVM-wide default time zone. Note This can be useful to set an application-level default time zone which differs from the JVM-wide default time zone. However, this requires each such application to operate against locally deployed Spring Framework jars. Do not deploy Spring as a shared library at the server level in such a scenario!
| |
| setLocale | back to summary |
|---|---|
| public static void setLocale(Locale locale) Associate the given Locale with the current thread, preserving any TimeZone that may have been set already. Will implicitly create a LocaleContext for the given Locale, not exposing it as inheritable for child threads.
| |
| setLocale | back to summary |
|---|---|
| public static void setLocale(Locale locale, boolean inheritable) Associate the given Locale with the current thread, preserving any TimeZone that may have been set already. Will implicitly create a LocaleContext for the given Locale.
| |
| setLocaleContext | back to summary |
|---|---|
| public static void setLocaleContext(LocaleContext localeContext) Associate the given LocaleContext with the current thread, not exposing it as inheritable for child threads. The given LocaleContext may be a
| |
| setLocaleContext | back to summary |
|---|---|
| public static void setLocaleContext(LocaleContext localeContext, boolean inheritable) Associate the given LocaleContext with the current thread. The given LocaleContext may be a
| |
| setTimeZone | back to summary |
|---|---|
| public static void setTimeZone(TimeZone timeZone) Associate the given TimeZone with the current thread, preserving any Locale that may have been set already. Will implicitly create a LocaleContext for the given Locale, not exposing it as inheritable for child threads.
| |
| setTimeZone | back to summary |
|---|---|
| public static void setTimeZone(TimeZone timeZone, boolean inheritable) Associate the given TimeZone with the current thread, preserving any Locale that may have been set already. Will implicitly create a LocaleContext for the given Locale.
| |