Solved

displaying a list of time zones using java

Posted on 2009-05-05
2
1,038 Views
Last Modified: 2012-05-06
how can i get a list of all of the timezones using java?

i want to use them for a dropdown and im also wondering how many timezones i should present to the user without overwhelming them.  Would only displaying 25 be enough?   What about determining their timezone based on their current city?

this is the 25 i was going to display:
var timezone = new Object();
timezone.Kwajalein="(GMT-12:00) Kwajalein";
timezone.Midway="(GMT-11:00) Midway Island, Samoa";
timezone.Hawaii="(GMT-10:00) Hawaii";
timezone.Alaska="(GMT-09:00) Alaska";
timezone.Pacific="(GMT-08:00) Pacific Time (USA & Canada)";
timezone.Arizona="(GMT-07:00) Arizona";
timezone.Mountain="(GMT-07:00) Mountain Time (USA & Canada)";
timezone.Mexico="(GMT-06:00) Mexico";
timezone.Central="(GMT-06:00) Central Time (USA & Canada)";
timezone.Indiana="(GMT-05:00) Indiana East, Colombia, Panama";
timezone.Eastern="(GMT-05:00) Eastern Time (USA & Canada)";
timezone.Bolivia="(GMT-04:00) Bolivia, Venezuela";
timezone.Atlantic="(GMT-04:00) Atlantic Time (Canada), Brazil West";
timezone.Newfoundland="(GMT-03:30) Newfoundland";
timezone.Guyana="(GMT-03:00) Guyana";
timezone.Brazil="(GMT-03:00) Brazil East, Greenland";
timezone.Mid="(GMT-02:00) Mid-Atlantic";
timezone.Azores="(GMT-01:00) Azores";
timezone.Gambia="(GMT) Gambia, Liberia, Morocco";
timezone.England="(GMT) England";
timezone.Tunisia="(GMT+01:00) Tunisia";
timezone.France="(GMT+01:00) France, Germany, Italy";
timezone.South="(GMT+02:00) South Africa";
timezone.Greece="(GMT+02:00) Greece, Ukraine, Romania, Turkey";
timezone.Iraq="(GMT+03:00) Iraq, Jordan, Kuwait";
timezone.Armenia="(GMT+04:00) Armenia";
timezone.Pakistan="(GMT+05:00) Pakistan, Russia";
timezone.india="(GMT+05:30) Bombay, Kalkutta, Madras, Neu Delhi";
timezone.Bangladesh="(GMT+06:00) Bangladesh, Russia";
timezone.Thailand="(GMT+07:00) Thailand, Russia";
timezone.China="(GMT+08:00) China, Hong Kong, Australia Western";
timezone.Singapore="(GMT+08:00) Singapore, Taiwan, Russia";
timezone.Japan="(GMT+09:00) Japan, Korea";
timezone.Guam="(GMT+10:00) Guam, Russia";
timezone.Australia="(GMT+10:00) Australia";
timezone.Solomon="(GMT+11:00) Solomon Islands";
timezone.Fiji="(GMT+12:00) Fiji";
timezone.New_Zealand="(GMT+12:00) New Zealand";
0
Comment
Question by:wrynn
2 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 24307883
e.g.
        for (String tz : java.util.TimeZone.getAvailableIDs()) {
            System.out.println(tz);
        }

Open in new window

0
 
LVL 92

Accepted Solution

by:
objects earned 500 total points
ID: 24309759
Don't display all timezones, there are too many
Instead try display timezones for the country as shown here
http://helpdesk.objects.com.au/java/can-i-find-all-available-timezones-for-a-country

0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
web application structure 18 102
configure dependency in POM for new database 3 34
JavaFX TableView not displaying correctly 3 59
Java program running SQL query 5 38
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question