【发布时间】:2013-08-28 19:54:29
【问题描述】:
我在 Spring MVC 上工作了一段时间,遇到了这个问题
我使用以下代码将应用程序时区设置为 New_York:
public class ApplicationListenerBean implements ApplicationListener {
@Override
public void onApplicationEvent(ApplicationEvent event) {
if (event instanceof ContextRefreshedEvent) {
TimeZone.setDefault(TimeZone.getTimeZone("America/New_York"));
System.out.println("Eastern time zone");
}
}
}
接下来,我正在提交一个表单并使用代码阅读它:
@RequestMapping("/saveschedule")
@ResponseBody
public String saveSchedule(
@ModelAttribute CommonSchedule schedule, ModelMap map, HttpServletRequest request) {
System.out.println(">>>>>>>>>>>>>>>> " + schedule.getSendingTime());
System.out.println(new Date());
}
如果我选择时间,15:30:00,我会得到输出 我得到以下输出:
>>>>>>>>>>>>>>>> Thu Jan 01 05:30:00 EST 1970
Mon Aug 26 06:20:01 EDT 2013
我想知道,spring mvc 表单提交为什么会得到 EST 而我的应用程序是 EDT
【问题讨论】: