Dgclock in Java

Version 2.3

Latest Release: Nov 15, 1996
Initial Release: Dec 05, 1995

This is a simple digital clock written in Java. This clock can display time and date of any place in world. The time can be displayed in 12 hour or 24 hour format. The foreground and background colors of the digits can be changed. The clock can be wrapped with a ornamental frame as well.

You will need a java capable browser like netscape in order to view the clock. I compiled and tested the applet on DEC OSF/1 3.2 with JDK 1.0.2 and netscape 3.01.

This applet uses double-buffering technique, therefore, you should not see any flickering at all.


- It may take some time to transfer -

My Time: Sorry Your browser is not java capable Your time: Berlin:
Dhaka: New York: GMT:

What's new

How to use it

If you want to use this applet in your web page, you have to download the archive first. Then, you have to extract the necessary files from the archive. The archive is available in 3 formats, gzipped tar, unix compressed tar and zipped archive. Download any one of the archives depending on what kind of de-compressor you have.


The following files will be extracted to the current working directory. Make sure you do not have any files with those name in the directory or they will be over written.
You need Dgclock.class, ColorFilter.class and dgstrip.gif in order to run the applet.

Please consider NOT running the applet remotely from this machine.

After downloading, copy the archive to your public_html directory (or wherever you keep your home pages).

If you downloaded the gzipped version, at the shell prompt, type:

    gunzip < jdgclock2.3.tar.gz | tar xvf -
    gzip -d < jdgclock2.3.tar.gz | tar xvf -
If you downloaded the unix compressed version, at the shell prompt, type:
    uncompress jdgclock2.3.tar.Z
    tar -xvf jdgclock2.3.tar
If you downloaded the zipped version, type:
    unzip jdgclk.zip

You do not need to compile the code in order to use it. Dgclock comes with pre-compiled classes Dgclock.class and ColorFilter.class. If you want to play with the source, please look at Dgclock.java (it is in the distribution as well).

Now, from your web page, call the applet as below:

    <applet code="Dgclock.class" width=100 height=30></applet>
This will show the visitor's time in 24 hour format. To display the time in 12 hour format, use:
    <applet code="Dgclock.class" width=100 height=30>
    <param name="TimeFormat" value="%I">
To display your time, you have to know your timezone offset from GMT. For example, if you live in New York, your timezone offset is 5 hours east of Greenwich meridian. Note, offset is negative for east and positive for west.

For New York:

    <applet code="Dgclock.class" width=100 height=30>
    <param name="TZ" value="GMT-0500">

Note, you can not use just -5, you must use the four digit offset starting with GMT+ or GMT-. If your timezone offset is 4 hours, 30 minutes west of Greenwich meridian, the param line will be:

    <param name="TZ" value="GMT+0430">
To display GMT, the param line will be:
    <param name="TZ" value="GMT+0000">
To display date with time:
    <applet code="Dgclock.class" width=100 height=30>
    <param name="TZ" value="GMT-0500">
    <param name="ShowDate" value="yes">

If you do not want to display the frame around the clock, use:

    <applet code="Dgclock.class" width=89 height=20>
    <param name="ShowFrame" value="no">

If you move the mouse cursor on the clock while it is running, the version information is displayed on netscape's status area. If you do not want this, use:

    <param name="ShowVersion" value="no">
If ShowVersion is "no", when the mouse pointer is moved over the clock, it will display the timezone offset from GMT in the netscape status area.

To change the foreground and background color of the digits, the parameters fg and bg can be used respectively.

    <param name="fg" value="red">
The value of fg and bg can be one of the following color names
    magenta, yellow,orange,
a 6 digit hex number like ff0000. Example:
    <param name="fg" value="yellow">
    <param name="bg" value="red">

    <param name="bg" value="d3b5b5">
    <param name="fg" value="000000">



Inspired by World TIme applet and Clock2 applet.


This applet is in the public domain. Do anything you like with it. It would be nice but not required if you give me the credit for it.If you are using this applet, please let me know. Bug reports, suggestions are always welcome!

Frequently Asked Question(s)

1. I followed your instructions exactly, but the clock does not show up. Instead it shows a solid rectangle. What's wrong?

Several things may cause this problem:

  1. File permission problem. Change the mode of the files accordingly (unix):
        chmod 644 ./Dgclock.class
        chmod 644 ./ColorFilter.class
        chmod 644 ./dgstrip.gif
    If you see the message Loading image...please wait! at netscape's status message area for ever, this is an indication that the image loading is failed possibly because it could not find the stip image file dgstrip.gif or the image file is are not readable.

  2. You are using an old version of web browser.


Version 2.3 Version 2.2

Version 2.1

Muhammad A Muquit

Last updated: November 15, 1996.