spring i18n 设置时区
2021-06-18 23:04
标签:work ISE exce let handle actor simple debug local public class TimeZoneChangeInterceptor extends HandlerInterceptorAdapter { public static final String DEFAULT_PARAM_NAME = "_timeZone"; @Override String newTimeZone = request.getParameter(DEFAULT_PARAM_NAME); TimeZone timeZone = TimeZone.getTimeZone(newTimeZone.toUpperCase()); if (localeResolver instanceof LocaleContextResolver) { return true; } spring i18n 设置时区 标签:work ISE exce let handle actor simple debug local 原文地址:https://www.cnblogs.com/wangtg/p/9706131.html
private static final Logger logger = LoggerFactory.getLogger(TimeZoneChangeInterceptor.class);
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
throws ServletException {
if (StringUtils.isEmpty(newTimeZone)) return true;
if (timeZone != null) {
logger.debug("CHANGE TIMEZONE:" + LocaleContextHolder.getTimeZone().getID() + " TO " + timeZone.getID());
LocaleResolver localeResolver = RequestContextUtils.getLocaleResolver(request);
((LocaleContextResolver) localeResolver).setLocaleContext(request, response, new SimpleTimeZoneAwareLocaleContext(LocaleContextHolder.getLocale(), timeZone));
}
}
}