Java DateFormat parse() 不尊重时区
Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("America/New_York"));
DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss Z");
df.setTimeZone(TimeZone.getTimeZone("America/New_York"));
try {
System.out.println(df.format(cal.getTime()));
System.out.println(df.parse(df.format(cal.getTime())));
} catch (ParseException e) {
e.printStackTrace();
}
结果如下:
2011-09-24 14:10:51 -0400
星期六 九月 24 20:10:51 CEST 2011
为什么当我解析从format()获得的日期时,它不尊重时区?