public class FixedLocaleContextResolver extends Object implements LocaleContextResolver
LocaleContextResolverimplementation that always returns a fixed locale and optionally time zone. Default is the current JVM's default locale.
Note: Does not support
setLocaleContext(org.springframework.web.server.ServerWebExchange, org.springframework.context.i18n.LocaleContext), as the fixed locale and
time zone cannot be changed.
|Constructor and Description|
Create a default FixedLocaleResolver, exposing a configured default locale (or the JVM's default locale as fallback).
Create a FixedLocaleResolver that exposes the given locale.
Create a FixedLocaleResolver that exposes the given locale and time zone.
|Modifier and Type||Method and Description|
Resolve the current locale context via the given exchange.
Set the current locale context to the given one, potentially including a locale with associated time zone information.
public FixedLocaleContextResolver(Locale locale)
locale- the locale to expose
public LocaleContext resolveLocaleContext(ServerWebExchange exchange)
The returned context may be a
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.
public void setLocaleContext(ServerWebExchange exchange, @Nullable LocaleContext localeContext)