Day light saving time and java [duplicate]
Possible Duplicate:
Get Dayligh开发者_JAVA技巧t Saving Transition Dates For Time Zones in Java
Is there a way to find the daylight saving time switch day and time for a specified timezone in java ?
Try to utilize: java.util.TimeZone (reference)
Here is a similar thread that gives an answer to your question:
Get Daylight Saving Transition Dates For Time Zones in Java
This information resides in TimeZone
and is unfortunately not accessible. You can get some of it using toString()
, but not in a very usable way:
for(final String timeZoneId : TimeZone.getAvailableIDs()){
System.out.println(TimeZone.getTimeZone(timeZoneId));
}
Output:
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]
etc.
精彩评论