Solved

displaying a list of time zones using java

Posted on 2009-05-05
2
1,047 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Enroll in June's Course of the Month

June's Course of the Month is now available! Every 10 seconds, a consumer gets hit with ransomware. Refresh your knowledge of ransomware best practices by enrolling in this month's complimentary course for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

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

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
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…
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:
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

726 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