Java Cookbook
Get all time zone ids
Problem:
You want to know what time zones are available on your system.
Solution:
Java uses the TimeZone class to handle date/time casting to and from UTC. A TimeZone is retrieved by specifying a string id. Most of these ids are Olsen time zone ids. You can retrieve an array of time zone ids by calling the static getAvailableIDs() method.
To get all available IDs:
//Get all Timezone ids
String[] ids = TimeZone.getAvailableIDs();
//Loop through ids and output
for(int x = 0; x < ids.length; x++){
System.out.println(ids[x]);
}
The output is very long, so I will omit it here.
If you are testing any of these recipes in Eclipse and the characters are not displaying correctly in your console visit http://i18ncookbook.com/eclipse_settings.
This site is ad supported. I hope you find something among our sponsors worth clicking. ;)
i18n search