TimeZone : Java Glossary
home T words local find no local find frame, full screen Google search web for topic jump to footer translate with Babelfish 2007-08-08 by Roedy Green ©1996-2008 Canadian Mind Products
Go to : punctuation 0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z (all)
TimeZone
A TimeZone is a Java class for a region of the earth that keeps the same time. If they keep different time in summer and winter, everyone is the region flips together. The TimeZone class describes the offset from UTC in summer and winter time and when the flips occur of a given timezone. To get the default TimeZone adjusted for the user’s location:

In ordinary use, a time zone is a region of the earth that keeps the same winter time. They may or may not all flip to summer time at the same time and some parts may not flip at all.

TimeZone Names and Offsets

The names for timezones used in Java comes from a database maintained by Arthur David Olson. For reasons only he understands, Pacific Standard Time is called America/Los_Angeles.

The reason that local time is different at different spots on the earth is a consequence of:

The reason we have time zones is to make synchronising railway (and later airline and TV) schedules easier. If we used natural time, based on observing the instant the sun were highest in the sky, every town would have its own slightly different clock from its immediate neighbours. This is how things used to be done in the days of the stagecoach.

You will see many different ways of specifying a time zone, including:

Here is a list of available TimeZones:

If the above TimeZone Java Applet does not work…

  1. This Java Applet needs Java 1.6 or later, version 1.6.0_06 recommended and a recent browser.
  2. You should see an Applet above looking much like the screenshot. If you don’t, the following should help you get it working:
  3. If you are using Microsoft Internet Explorer, try another browser. Seriously. Microsoft has taken great pains, over and over, to screw up Java and every other mult-platform standardisation.
  4. If you are using Internet Explorer 7, you must allow blocked content permission for Active X to run. This also gives permission to Java to run. Click the Information bar, and then click Allow blocked content. Unfortunately, this also allows dangerous ActiveX code to run. However, you must do this in order to get access to perfectly-safe Java Applets running in a sandbox. This is part of Microsoft’s war on Java. Don’t put up with it! Use a different browser.
  5. To ensure your Java is up to date, check with Wassup.
  6. If the above Java Applet does not work, check the Java console for error messages.
  7. If the above Applet does not work, you might have better luck with the downloadable version.
  8. If you still can’t get the program working click HELP for more detail.
  9. If you can’t get the program working after trying the advice above and from the HELP button below, have bugs to report or ideas to improve the program or its documentation, please send me an email atemail Roedy Green.
Java powered   Get New Java  Get New Browser   Help

Gotchas

See GNU Timezone classes that correct for historical changes and leap seconds.

You can find out the current time at any place on the globe at WorldTimeServer.com. It will tell you the offset from UTC, but not the timezone name.

Unfortunately, you can’t extract the rules about when daylight savings go into effect from a TimeZone object. I suppose if you were patient you could deduce them by binary search on inDaylightTime. You could also study the code that is used to construct all the TimeZone objects in rt.jar, or the various locale jars and decompile and parse that to extract the information.

Here are the rules for the switch days in the EU. There are some algorithms to compute them.

Switch days are decided politically so can change erratically, especially in the USA, albeit with advance notice. In ancient Rome, one could bribe officials to have months lengthened or shortened, so we have made progress.

Learning More

Sun’s Javadoc on the TimeZone class : available:

CMP_homejump to top
CMP logo
feedback Please email your feedback for publication, errors, omissions, broken/redirected link reports
and suggestions to improve this page to Roedy Green : feedback email
made with CSS
HTML Checked!
ICRA ratings logo
mindprod.com IP:[65.110.21.43]
Your face IP:[38.103.63.16] The information on this page is for non-military use only.
You are visitor number 23,083. Military use includes use by defence contractors.
You can get a fresh copy of this page from: or possibly from your local J: drive (Java virtual drive/Mindprod website mirror)
http://mindprod.com/jgloss/timezone.html J:\mindprod\jgloss\timezone.html