你可以嘗試設置使用America/New_York
時區:
TimeZone.setDefault(TimeZone.getTimeZone("America/New_York"));
System.out.println(TimeZone.getDefault());
此打印:
sun.util.calendar.ZoneInfo[id="America/New_York",offset=-18000000,dstSavings=3600000,useDaylight=true,transitions=235,lastRule=java.util.SimpleTimeZone[id=America/New_York,offset=-18000000,dstSavings=3600000,useDaylight=true,startYear=0,startMode=3,startMonth=2,startDay=8,startDayOfWeek=1,startTime=7200000,startTimeMode=0,endMode=3,endMonth=10,endDay=1,endDayOfWeek=1,endTime=7200000,endTimeMode=0]]
也許一個側面說明:
可以列出使用所有可用的時區的ID:
String[] ids = TimeZone.getAvailableIDs();
for (String id : ids) {
System.out.println(TimeZone.getTimeZone(id).getID());
}
來源
2017-07-11 14:03:48
eol