Solved

displaying a list of time zones using java

Posted on 2009-05-05
2
1,034 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Java - Why doesn't this JFrame work 3 58
servlet  URL Rewriting 1 36
even odd program using while loop 3 40
login form jsp example 2 24
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
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 how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:

813 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now