org.springframework.web.servlet

## Interface LocaleContextResolver

- All Superinterfaces:
    LocaleResolver
  All Known Implementing Classes:
    AbstractLocaleContextResolver, CookieLocaleResolver, FixedLocaleResolver, SessionLocaleResolver

      public interface LocaleContextResolver
      extends LocaleResolver

  Extension of `LocaleResolver` that adds support for a rich locale context (potentially including locale and time zone information).
  Since:
    4.0
  Author:
    Juergen Hoeller
  See Also:
    `LocaleContext`, `TimeZoneAwareLocaleContext`, `LocaleContextHolder`, `RequestContext.getTimeZone()`, `RequestContextUtils.getTimeZone(javax.servlet.http.HttpServletRequest)`

- - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method and Description
    --- | ---
    `LocaleContext` | `resolveLocaleContext(HttpServletRequest request)` Resolve the current locale context via the given request.
    `void` | `setLocaleContext(HttpServletRequest request, HttpServletResponse response, LocaleContext localeContext)` Set the current locale context to the given one, potentially including a locale with associated time zone information.

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

      `resolveLocale, setLocale`

- - ### Method Detail

    - #### resolveLocaleContext

          LocaleContext resolveLocaleContext(HttpServletRequest request)

      Resolve the current locale context via the given request.

      This is primarily intended for framework-level processing; consider using `RequestContextUtils` or `RequestContext` for application-level access to the current locale and/or time zone.

      The returned context may be a `TimeZoneAwareLocaleContext`, containing a locale with associated time zone information. Simply apply an `instanceof` check and downcast accordingly.

      Custom resolver implementations may also return extra settings in the returned context, which again can be accessed through downcasting.

      Parameters:
        `request` - the request to resolve the locale context for
      Returns:
        the current locale context (never `null`
      See Also:
        `LocaleResolver.resolveLocale(HttpServletRequest)`, `RequestContextUtils.getLocale(javax.servlet.http.HttpServletRequest)`, `RequestContextUtils.getTimeZone(javax.servlet.http.HttpServletRequest)`

    - #### setLocaleContext

          void setLocaleContext(HttpServletRequest request,
                                @Nullable
                                HttpServletResponse response,
                                @Nullable
                                LocaleContext localeContext)

      Set the current locale context to the given one, potentially including a locale with associated time zone information.
      Parameters:
        `request` - the request to be used for locale modification
        `response` - the response to be used for locale modification
        `localeContext` - the new locale context, or `null` to clear the locale
      Throws:
        `UnsupportedOperationException` - if the LocaleResolver implementation does not support dynamic changing of the locale or time zone
      See Also:
        `LocaleResolver.setLocale(HttpServletRequest, HttpServletResponse, Locale)`, `SimpleLocaleContext`, `SimpleTimeZoneAwareLocaleContext`