spring-framework / org.springframework.web.servlet.support / RequestContextUtils / getTimeZone

getTimeZone

@Nullable open static fun getTimeZone(request: HttpServletRequest): TimeZone

Retrieve the current time zone from the given request, using the TimeZoneAwareLocaleResolver bound to the request by the DispatcherServlet (if available), falling back to the system's default time zone.

Note: This method returns null if no specific time zone can be resolved for the given request. This is in contrast to #getLocale where there is always the request's accept-header locale to fall back to.

Consider using org.springframework.context.i18n.LocaleContextHolder#getTimeZone() which will normally be populated with the same TimeZone: That method only differs in terms of its fallback to the system time zone if the LocaleResolver hasn't provided a specific time zone (instead of this method's null).

Parameters

request - current HTTP request

Return
the current time zone for the given request, either from the TimeZoneAwareLocaleResolver or null if none associated

See Also
#getLocaleResolverorg.springframework.context.i18n.LocaleContextHolder#getTimeZone()