Solved

displaying a list of time zones using java

Posted on 2009-05-05
2
1,026 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
Comment Utility
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
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
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 tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

763 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

6 Experts available now in Live!

Get 1:1 Help Now