白天节省时间和java

时间:2011-04-08 12:06:49

标签: java dst

  

可能重复:
  Get Daylight Saving Transition Dates For Time Zones in Java

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

3 个答案:

答案 0 :(得分:1)

尝试利用:java.util.TimeZone(reference

答案 1 :(得分:0)

这是一个类似的主题,可以回答你的问题:

Get Daylight Saving Transition Dates For Time Zones in Java

答案 2 :(得分:0)

此信息位于TimeZone,但遗憾的是无法访问。您可以使用toString()获取部分内容,但不能以非常有用的方式获取:

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

<强>输出:

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]