关于dst:日光节省时间和java

Day light saving time and java

本问题已经有最佳答案,请猛点这里访问。

Possible Duplicate:
Get Daylight Saving Transition Dates For Time Zones in Java

有没有办法在java中找到指定时区的夏令时切换日期和时间?


尝试利用:java.util.TimeZone(参考)


此信息位于TimeZone中,但遗憾的是无法访问。 你可以使用toString()获得一些,但不能以一种非常有用的方式:

1
2
3
for(final String timeZoneId : TimeZone.getAvailableIDs()){
    System.out.println(TimeZone.getTimeZone(timeZoneId));
}

输出:

1
2
3
4
5
6
7
8
9
sun.util.calendar.ZoneInfo[id="Etc/GMT+2",offset=-7200000,dstSavings=0,useDaylight=false,transitions=0,lastRule=null]
sun.util.calendar.ZoneInfo[id="America/Scoresbysund",offset=-3600000,dstSavings=3600000,useDaylight=true,transitions=118,lastRule=java.util.SimpleTimeZone[id=America/Scoresbysund,offset=-3600000,dstSavings=3600000,useDaylight=true,startYear=0,startMode=2,startMonth=2,startDay=-1,startDayOfWeek=1,startTime=3600000,startTimeMode=2,endMode=2,endMonth=9,endDay=-1,endDayOfWeek=1,endTime=3600000,endTimeMode=2]]
sun.util.calendar.ZoneInfo[id="Atlantic/Azores",offset=-3600000,dstSavings=3600000,useDaylight=true,transitions=221,lastRule=java.util.SimpleTimeZone[id=Atlantic/Azores,offset=-3600000,dstSavings=3600000,useDaylight=true,startYear=0,startMode=2,startMonth=2,startDay=-1,startDayOfWeek=1,startTime=3600000,startTimeMode=2,endMode=2,endMonth=9,endDay=-1,endDayOfWeek=1,endTime=3600000,endTimeMode=2]]
sun.util.calendar.ZoneInfo[id="Atlantic/Cape_Verde",offset=-3600000,dstSavings=0,useDaylight=false,transitions=6,lastRule=null]
sun.util.calendar.ZoneInfo[id="Etc/GMT+1",offset=-3600000,dstSavings=0,useDaylight=false,transitions=0,lastRule=null]
sun.util.calendar.ZoneInfo[id="Africa/Abidjan",offset=0,dstSavings=0,useDaylight=false,transitions=3,lastRule=null]
sun.util.calendar.ZoneInfo[id="Africa/Accra",offset=0,dstSavings=0,useDaylight=false,transitions=17,lastRule=null]
sun.util.calendar.ZoneInfo[id="Africa/Bamako",offset=0,dstSavings=0,useDaylight=false,transitions=5,lastRule=null]
sun.util.calendar.ZoneInfo[id="Africa/Banjul",offset=0,dstSavings=0,useDaylight=false,transitions=4,lastRule=null]

等等


这是一个类似的线程,可以回答您的问题:

获取Java中时区的夏令时转换日期