org.springframework.web.servlet.i18n

## Class AbstractLocaleContextResolver

- java.lang.Object
- - org.springframework.web.servlet.i18n.AbstractLocaleResolver
  - - org.springframework.web.servlet.i18n.AbstractLocaleContextResolver

- All Implemented Interfaces:
    LocaleContextResolver, LocaleResolver
  Direct Known Subclasses:
    FixedLocaleResolver, SessionLocaleResolver

      public abstract class AbstractLocaleContextResolver
      extends AbstractLocaleResolver
      implements LocaleContextResolver

  Abstract base class for `LocaleContextResolver` implementations. Provides support for a default locale and a default time zone.

  Also provides pre-implemented versions of `resolveLocale(javax.servlet.http.HttpServletRequest)` and `setLocale(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, java.util.Locale)`, delegating to `LocaleContextResolver.resolveLocaleContext(javax.servlet.http.HttpServletRequest)` and `LocaleContextResolver.setLocaleContext(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, org.springframework.context.i18n.LocaleContext)`.

  Since:
    4.0
  Author:
    Juergen Hoeller
  See Also:
    `AbstractLocaleResolver.setDefaultLocale(java.util.Locale)`, `setDefaultTimeZone(java.util.TimeZone)`

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `AbstractLocaleContextResolver()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `TimeZone` | `getDefaultTimeZone()` Return the default TimeZone that this resolver is supposed to fall back to, if any.
    `Locale` | `resolveLocale(HttpServletRequest request)` Resolve the current locale via the given request.
    `void` | `setDefaultTimeZone(TimeZone defaultTimeZone)` Set a default TimeZone that this resolver will return if no other time zone found.
    `void` | `setLocale(HttpServletRequest request, HttpServletResponse response, Locale locale)` Set the current locale to the given one.

    - ### Methods inherited from class org.springframework.web.servlet.i18n.AbstractLocaleResolver

      `getDefaultLocale, setDefaultLocale`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface org.springframework.web.servlet.LocaleContextResolver

      `resolveLocaleContext, setLocaleContext`

- - ### Constructor Detail

    - #### AbstractLocaleContextResolver

          public AbstractLocaleContextResolver()

  - ### Method Detail

    - #### setDefaultTimeZone

          public void setDefaultTimeZone(TimeZone defaultTimeZone)

      Set a default TimeZone that this resolver will return if no other time zone found.

    - #### getDefaultTimeZone

          public TimeZone getDefaultTimeZone()

      Return the default TimeZone that this resolver is supposed to fall back to, if any.

    - #### resolveLocale

          public Locale resolveLocale(HttpServletRequest request)

      Description copied from interface: `LocaleResolver`
      Resolve the current locale via the given request. Can return a default locale as fallback in any case.
      Specified by:
        `resolveLocale` in interface `LocaleResolver`
      Parameters:
        `request` - the request to resolve the locale for
      Returns:
        the current locale (never `null`)

    - #### setLocale

          public void setLocale(HttpServletRequest request,
                                HttpServletResponse response,
                                Locale locale)

      Description copied from interface: `LocaleResolver`
      Set the current locale to the given one.
      Specified by:
        `setLocale` in interface `LocaleResolver`
      Parameters:
        `request` - the request to be used for locale modification
        `response` - the response to be used for locale modification
        `locale` - the new locale, or `null` to clear the locale