public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
     throws Exception {
   JodaTimeContext context = new JodaTimeContext();
   context.setTimeZone(getTimeZone(request));
   JodaTimeContextHolder.setJodaTimeContext(context);
   return true;
 }
Пример #2
0
 private void setTimeZoneForDateTimeFilter() {
   JodaTimeContext jodaTimeContext = getJodaTimeContext();
   // check JodaTimeContext first and use it if set
   if (jodaTimeContext != null)
     engine.getConfiguration().setTimezone(jodaTimeContext.getTimeZone().toTimeZone());
   else { // try attrib param next
     String timeZone = (String) getAttributesMap().get(PARAM_TIMEZONE);
     if (timeZone != null) {
       engine.getConfiguration().setTimezone(TimeZone.getTimeZone(timeZone));
       JodaTimeContext context = JodaTimeContextHolder.getJodaTimeContext();
       if (context == null) context = new JodaTimeContext();
       context.setTimeZone(DateTimeZone.forID(timeZone));
       JodaTimeContextHolder.setJodaTimeContext(context);
     }
   }
 }
 public void postHandle(
     HttpServletRequest request,
     HttpServletResponse response,
     Object handler,
     ModelAndView modelAndView)
     throws Exception {
   if (modelAndView != null) {
     modelAndView.addObject("jodaTimeContext", JodaTimeContextHolder.getJodaTimeContext());
   }
 }
 public void afterCompletion(
     HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex)
     throws Exception {
   JodaTimeContextHolder.resetJodaTimeContext();
 }