digital/analogWorldTimeClock

Why this?

I wanted a world time clock applet where one can give the daylight saving time (DST) settings as parameters, with an arbitary number of clocks and with both an analog and digital display. Therefore I started with the clock example in the book Java in 21 Tagen and coded this world time clock applet, which is up to my knowledge one of the most highly costumizable ones available on the web.
I am proud to be listed at The Java Clock Shop (by the way, there you'll find other nice clocks, too) and published on the CD "1000 Best JAVA Applets Collection" by Eongenius Enterprise (they say: "an extremely good world time applet").

Can I have the source code?

Sure. Here it is: WorldTimeClock.java.
Take it, use it, change it, do whatever you want with it. I guess it's not a text book example for JAVA programming but it works.

Can I have this on my web page?

Sure. Follow the steps:

1. Upload this file to your web directory: WorldTimeClock.class.

2. Add the following code to your web page:

<APPLET CODE="WorldTimeClock.class" CODEBASE="my directory" WIDTH="710" HEIGHT="170">
</APPLET>

Replace my directory by the directory, where you have the file of step 1 or remove the whole CODEBASE="my directory" if it's in the same directory as your web page. Later you will have to adjust the width and the height of the applet depending on your settings.

3. Add a new line before the </APPLET> tag and enter the following code:

<PARAM NAME="name" VALUE="value">

Now replace name by the name of the parameter you want to change and value by the value you want to change it to from the table below.

4. Repeat step 3 for all the parameters you want to change. Note that every parameter has a default value, so you only have to give the ones you want to change. Some parameter values consist of more than one argument, separated by comma. The values of the parameters which determine time and DST settings for the cities must have an equal number of arguments (that means, the number of commas must be equal). Everything before the first comma, between the commas and after the last comma is treated as an argument, so don't type spaces after the commas.
And here are all the possible parameters:

parameterfunctionpossible valuesdefault value
names the names of the cities a list of the names, separated by commas Guatemala,New York,Rio de Janeiro, London,Moscow,Sydney
addnames1
addnames2
...
optional additional city names a list of the names, separated by commas  
offset the offset of the local time from GMT, without DST a list of integers with an optional minus-sign (don't type plus-sign) -6,-5,-3,0,3,10
unit whether the offset is given in hours or minutes hour or min hour
usedst whether the cities are observing DST a list of no and yes no,yes,yes,yes,yes,yes
startmonth the month DST starts a list of integers, where 1 means January, 2 February ... ,4,10,3,3,10
startday the day of the week DST starts a list of integers, where 0 means Sunday, 1 Monday ... ,0,0,0,0,0
startweek whether DST starts on the first or the last day of the week of the month a list of 1 and -1 where 1 means the first and -1 the last week ,1,1,-1,-1,-1
endmonth the month DST ends a list of integers, where 1 means January, 2 February ... ,10,2,10,10,3
endday the day of the week DST ends a list of integers, where 0 means Sunday, 1 Monday ... ,0,0,0,0,0
endweek whether DST ends on the first or the last day of the week of the month a list of 1 and -1 where 1 means the first and -1 the last week ,-1,-1,-1,-1,-1
The DST rules can be found on many websites, see e.g. www.timeanddate.com/worldclock.
timeformat whether to show the time in 24 or 12 hour format 12 (this gives something like "9:33:45 AM") or 24 (this gives something like "09:33:45") 24
weekdays provides the words for the weekdays a list of 7 words, where the first one corresponds to Sunday, the second to Monday ... Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday
dateformat the order and delimiters of the date contributions the characters d, m, y in the order in which day, month and year will appear, separated by the desired one-character delimiters (e.g. d.m.y) y/m/d
showanalog whether to show the analog display yes or no yes
showam whether to show "AM" or "PM" below the analog display yes or no yes
showdsta whether to show "DST" below the analog display when the city is running under DST yes or no no
showseca whether to show the seconds in the analog display yes or no yes
showdigital whether to show the digital display yes or no no
showdstd whether to show "DST" in the digital display when the city is running under DST yes or no no
showsecd whether to show the seconds in the digital display yes or no yes
showday whether to show the day of the week yes or no yes
showdate whether to show the date yes or no yes
cityfont type, face and size of the font for the city a list type,face,size, where type can be any font the browser can handle, face can be plain, bold or italic and size an integer (in points) TimesRoman,plain,12
timefont type, face and size of the font for the time the same as cityfont
datefont type, face and size of the font for the day of the week and the date the same as cityfont
clocksize the diameter of the analog display an integer (in points) 60
hspace the space between the clocks and the margin an integer (in points) 12
vspace the space between the lines an integer (in points) 0
fgcolor the foreground-color a list of three integers between 0 and 255, determining the contributions of red, green and blue 0,0,0 (this gives black)
bgcolor the background-color the same as fgcolor 255,255,255 (this gives white)
bdcolor the border-color the same as fgcolor
bdwidth the width of the border an integer (in points) 1

Here is an example for the complete code you have to add to your web page:

<APPLET CODE="WorldTimeClock.class" WIDTH="700" HEIGHT="210">
<PARAM NAME="names" VALUE="Guatemala,New York,Rio de Janeiro,London,Moscow,Sydney">
<PARAM NAME="addnames1" VALUE=",Ottawa,Sao Paulo,Dublin,,Port Moresby">
<PARAM NAME="addnames2" VALUE=",,,Reykjavik,,">
<PARAM NAME="offset" VALUE="-6,-5,-3,0,3,10">
<PARAM NAME="usedst" VALUE="no,yes,yes,yes,yes,yes">
<PARAM NAME="startmonth" VALUE=",4,10,3,3,10">
<PARAM NAME="startday" VALUE=",0,0,0,0,0">
<PARAM NAME="startweek" VALUE=",1,1,-1,-1,-1">
<PARAM NAME="endmonth" VALUE=",10,2,10,10,3">
<PARAM NAME="endday" VALUE=",0,0,0,0,0">
<PARAM NAME="endweek" VALUE=",-1,-1,-1,-1,-1">
<PARAM NAME="timeformat" VALUE="12">
<PARAM NAME="showam" VALUE="no">
<PARAM NAME="showdigital" VALUE="yes">
<PARAM NAME="showdstd" VALUE="yes">
<PARAM NAME="cityfont" VALUE="TimesRoman,bold,12">
<PARAM NAME="timefont" VALUE="Courier,plain,14">
<PARAM NAME="datefont" VALUE="TimesRoman,italic,12">
<PARAM NAME="bdcolor" VALUE="255,0,0">
</APPLET>

This gives the applet you see on the top of this page. (It does as well, if you don't give the first 11 parameters, except the second and the third, because they have the default values.)

5. Adjust width and height of the applet so that they fit your settings.

6. Play around with the parameters and create the clock you like!

It doesn't work!

Check if all the parameters are correctly given (equal numbers of arguments for all parameters related to the individual cities, no spaces after the commas). Still not working? Send me an email to pge97afn@yahoo.de.

It works!

Please put somewhere on your page a link to this page to let others know where you have the clock from.
If you have any comments, questions or ideas which functions I should include, feel free to send me an email to pge97afn@yahoo.de.

And so it does on the following web sites:

russ-gladden.dyndns.org/webcam2.html
www.fitter1.com/contact_us.html
el-tiempo-pr.com/PagsPrin/hora.html
www.youheard.co.uk
pub97.ezboard.com/bknightsofthunder91285
www.users.on.net/~ilan/links.htm
www.travelwideservices.com
members.tripod.com/~cbrooks
mywebpages.comcast.net/kunzet/index.htm
www.plexus.com
www.prontos.net/ONLINE/ProntosTech
www.gamah.net
www.geoff.ws
www.ees.net.nz
www.geocities.com/jrcadw
whitewolf77.tripod.com/home.html
home.comcast.net/~igpl/Resources.html
ve2.etsmtl.ca/~va2mek/vacances.htm
www.a1rport.com/home.htm
www.paradortravel.com
www.zurichcci.ch
www.ozgeorge.net

Is it working on your page too? Let me know: pge97afn@yahoo.de.

P.S. The clock does not appear on www.marvelclan.com. Find out why.

visitors:

1