WorldClock Demo page

Demo page for WorldClock Java applet with explanation of parameters







Thai version of this page (requires Thai Fonts)


Above are total of nine instances of my WorldClock applet. You should see two large clocks above five smaller ones. The two large ones display your local time and that in Singapore. The five smaller clocks below display the times in New York, Bangkok, London, Berlin, and finally one which displays an custom timezone just 10 mins ahend of GMT.

Map of timezones around the world...

Applet usage

You can link to the the applet, but must not copy it as it is copyrighted material. If you include a link please let me know so that I know where it's being used and so that I can drop you a note when I make any code changes.

To include it on your page you need to include an HTML APPLET tag (or OBJECT) in your HTML. For example:

<APPLET archive="WorldClock.jar" codebase="http://argray.org/worldclock/" code="WorldClock.class" width="xxx" height="yyy">
</APPLET>

Replace xxx & yyy with the number of pixels you want the applet to occupy in the X and Y dimensions. Any parameters you wish to specify need to go after the opening <APPLET> tag and before the closing </APPLET>

 

Parameters

The WorldClock applet supports the following parameters via the Applet element
<PARAM NAME="name"  VALUE="value">

  • BGCOLOUR  colour of the background - you're likely to want this to match whatever the browser is using.
  • DEBUG a value  from 0 to 10 indicating the level of debugging output to be sent to the Java log/console. A value of 2 will cause various geometry information to be dumped to the Java log - this is useful when sizing the applet. Values higher than 5 are not useful without the source code. Beware that values above 2 will create a lot of log data in a short space of time, possibly with detrimental effects on your browser.
  • DIGITAL true/false, show the digital panel ? Default is TRUE
  • DIGITALFORMAT String specifying the format of the digital display. The keyword SYSTEM may be specified, in which case the display will be in the format as configured in the displaying browser/workstation.

    Format string examples;
    Format Pattern Result
    "yyyy.MM.dd G 'at' hh:mm:ss z" 1996.07.10 AD at 15:08:56 PDT
    "EEE, MMM d, ''yy" Wed, July 10, '96
    "h:mm a" 12:08 PM
    "hh 'o''clock' a, zzzz" 12 o'clock PM, Pacific Daylight Time
    "K:mm a, z" 0:00 PM, PST
    "yyyyy.MMMMM.dd GGG hh:mm aaa" 1996.July.10 AD 12:08 PM

    These format specifiers are fully documented in the Java API - see SimpleDateFormat for a full list. If not specified the default format string used for a per-second updated clock is   "HH:mm:ss EEE d MMM"

    Note if your format string includes "ss" (seconds) then you probably want to ensure that SECONDS is TRUE, otherwise curious effects will be observed. Without the second hand the display is normally only updated every 60 seconds, on the minute. However any event that causes the applet's window to be redrawn will likely result in the digital display showing a few seconds more.
  • DRAWDISC TRUE or FALSE whether to draw the disc of the clock face or not. Default is TRUE
  • FACECOLOUR colour of the clock face. Alternatively the keyword TRANSPARENT will allow the background colour/image to show through. Please note that this option forces a full redraw on every update, thereby increasing CPU load.
  • FACECOLOUR2 colour of clock face when mouse enters applet
  • FGCOLOUR  general foreground drawing colour.
  • HANDCOLOUR  colour of the hour and minute hands.
  • LABEL The text to be placed immediately below the clock. Alternatively the keyword NONE will suppress the display of label. By default the the Timezone name, as reported by the browser, is used.
  • NUMCOLOUR  colour of the numerals on clock face.
  • NUMERALS  the type of numerals to be shown on the clock face.  Only ROMAN and ARABIC are currently recognised.
  • NUMMARKMODE Value indicating the frequency of numeral marking on the clock face;
    2 show the numerals representing all the hour positions 1-12.
    1 show only the numerals representing hours 12,3,6,9 - DEFAULT
    0 don't show any numerals.
  • POLYGONn Specifies the polygon to be used to draw Hand n. Polygons are specified with a series of x,y pairs, with 0 being the center, and 100 being the radius of the clock face. The first large clock on this page includes an example of Polygon use.
  • SECCOLOUR  colour of the second hand.
  • SECONDS  true/false, display second hands ? Default value is FALSE
  • SMOOTH  true/false?, enable smooth(er) hand motion. This causes the second hand to be updated 10 times a second and also reduces the granularity of the hour and minute hands. Has no effect unless SECONDS is TRUE. Be warned that this mode increases CPU and memory usage enormously, looks great though ! Default value is FALSE
  • TICKMARKMODE Value indicating the frequency of tick marks the clock face;
    3 show all tick marks representing all hour and minute positions. DEFAULT
    2 show tick marks only at the hour positions 1-12.
    1 show only tick marks at the hours 12,3,6,9
    0 don't show any tickmarks.
  • TIMEZONE  A string indicating desired timezone. Usually in the form Continent/City, e.g "America/New York". Can also be specified as a hour & minute offset from GMT, see TimeZone.getTimeZone() for the exact syntax.
    This is dependant on the version of Java used by your browser, some older browsers only support the old ( and ambigous ) three letter codes. To cope with this the applet has a number of built-in timezones which will be used if the specified zone is not supported by the browser. An unrecognised timezone will cause the applet to list the valid ids to the browser's Java log/console window, the clock will run, but with a timezone of "GMT" .
    Please also note that some older browser appear to wrongly report the default timezone as GMT - The applet has no way of detecting this fault...
  • TKCOLOUR  colour of the tick marks on clock face.

Note on Colours
All colour parameters take either the standard HTML hexadecimal representation of a colour, or one of the (few) Java built-ins. These are:
BLACK, BLUE, CYAN, DARKGREY, GREY, GREEN, LIGHTGREY, MAGENTA, ORANGE, PINK, RED,WHITE, YELLOW.

Finally if you're an American and believe Colour should be mis-spelt "C-O-L-O-R", well you've been wrong all these years, and I suggest you buy a copy of the Concise Oxford English dictionary.....

Programmer's note

Every effort has been made to minimise the impact of these clocks on your system.
If you can see this page properly it means there are at least 9 Java programs running on your system at the same time. Despite this you should not notice any degradation in your system's performance - this is because the clocks only use processor time when the time actually changes. Thus the clocks showing a second hand only run once a second, and those without only once a minute. Contrast this with other algorithms which actually run several times a second..

Additionally, the complex floating point arithmetic needed to compute the position of hands and face components is only performed when the clock is initially sized and positioned by your Browser. Thus there are no numerically intensive trigonometric functions being routinely performed.

The applet was written using Java SDK 1.1.5, there are no Java2 features used. This should ensure that it works on most current browsers.

Browsers with a JavaVM below version 1.2 will use the Built-in timezone support, as only with 1.2 are the long timezone names fully supported. At the time of writing I believe only Netscape 6 supports 1.2 natively.

Planned enchancements

These are just some ideas that may, one day, be implemented

  • Square Face
  • Glyph numerals to allow clock to show numerals from non-latin languages without browser font support - e.g. Japanese, Chinese, Thai, etc...
  • Irish mode Clock faces draw backward, and motion is counter-clockwise
  • Battery low mode to mimic what a Swiss army watch does when battery is low. I.E. Second hand only updates every 4 seconds, otherwise keeps perfect time...cute... Probably implement this with a random factor so that sometimes clock flips into this mode.
  • Watch styles mimicing look-and-feel of watch manufacturers such as Rolex, Breitlung, Swiss Army, etc..





Clocks on Jewish town hall in Prague
Jewish town hall, Prague


Clock outside national museum in Singapore
National museum, Singapore
Home GCD calculator WorldClock Thai Guide Services Contact us