我的比赛中的TZ是GMT + 5.
final DateTime date1 = dtf.parseDateTime("1979-04-29");
final DateTime date2 = dtf.parseDateTime("1979-05-12");
final DateTime date3 = dtf.parseDateTime("1979-04-02");
final DateTime date4 = dtf.parseDateTime("1979-04-15");
System.err.println(date1.toString());
System.err.println(date2.toString());
System.err.println(date3.toString());
System.err.println(date4.toString());
输出
1979-04-29T00:00:00.000-05:00
1979-05-12T00:00:00.000-04:00
1979-04-02T00:00:00.000-05:00
1979-04-15T00:00:00.000-05:00
-04?为什么呢?
如果添加
DateTimeZone.setDefault(DateTimeZone.forID("Etc/GMT+5"));
之前,然后输出
1979-04-29T00:00:00.000-05:00
1979-05-12T00:00:00.000-05:00
1979-04-02T00:00:00.000-05:00
1979-04-15T00:00:00.000-05:00