Hi, can anyone have an idea which will give you the all available timezones with the help of java? I want to do it in java. If you have source code regarding this in another language then also do. Please, reply me as soon as possible.
Hi, can anyone have an idea which will give you the all available timezones with the help of java? I want to do it in java. If you have source code regarding this in another language then also do. Please, reply me as soon as possible.
HI, I don't know how to do this. But, I have come to know the some of the following methods of java.util clas TimeZone as follows:
Last edited by Reegan; 30-11-2009 at 10:13 AM.
Hi, to Retrieve Information on All Available Time Zones you need to use the following example which will lists all time zones known by the Java Development Kit.
Code:Date today = new Date(); String[] zoneIds = TimeZone.getAvailableIDs(); for (int i=0; i<zoneIds.length; i++) { TimeZone tz = TimeZone.getTimeZone(zoneIds[i]); String shortName = tz.getDisplayName(tz.inDaylightTime(today), TimeZone.SHORT); String longName = tz.getDisplayName(tz.inDaylightTime(today), TimeZone.LONG); int rawOffset = tz.getRawOffset(); int hour = rawOffset / (60*60*1000); int min = Math.abs(rawOffset / (60*1000)) % 60; boolean hasDST = tz.useDaylightTime(); boolean inDST = tz.inDaylightTime(today); }
HI, this is the best and simple example in java which will give you the all available time zones. I don't think that it needs explanation.
List of all the available Time zones ID in JDK :Code:import java.util.TimeZone; public class AllTimeZones { public static void main(String args[]) { String[] ID= TimeZone.getAvailableIDs(); for(int i=0;i<ID.length;i++) { System.out.println("TimeZone ["+(i+1)+"] ==>"+ TimeZone.getTimeZone(ID[i])); } } }
Bookmarks