?
Solved

displaying a list of time zones using java

Posted on 2009-05-05
2
Medium Priority
?
1,057 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 2000 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
Suggested Courses
Course of the Month17 days, 13 hours left to enroll

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