Apologies for the recent interruption in service; I accidentally allowed the domain to expire.

Millennium Clock Source

(Last Update 15:31 on Wednesday, 12 January 2000)

// Clock applet
// Neil Rashbrook
// Last modified December 16 1999
import java.awt.*;
public class clock extends java.applet.Applet implements Runnable {
private boolean fast;
private int units = 100, pos = 9;
private long update[];
private Image digits[], sep;
private Thread timer;
private long y2000 = new java.util.Date(100, 0, 1).getTime();
public boolean imageUpdate(Image img, int infoflags, int x, int y, int width, int height) {
if ((infoflags & ALLBITS) != 0) {
fast = false;
repaint();
}
return true;
}
private void findDate() {
try {
y2000 = new java.util.Date(Integer.parseInt(getParameter("year")) - 1900,
Integer.parseInt(getParameter("month")) - 1,
Integer.parseInt(getParameter("day"))).getTime();
y2000 = new java.util.Date(Integer.parseInt(getParameter("year")) - 1900,
Integer.parseInt(getParameter("month")) - 1,
Integer.parseInt(getParameter("day")),
Integer.parseInt(getParameter("hour")),
Integer.parseInt(getParameter("minute")),
Integer.parseInt(getParameter("second"))).getTime();
} finally {
return;
}
}
public String getAppletInfo() {
return "Clock Applet © 1999 Neil Rashbrook";
}
public String[][] getParameterInfo() {
return new String[][] {
{"units", "String", "Seconds, Minutes, Hours or Days"},
{"year", "int", "YYYY/MM/DD defaults to 2000/01/01"},
{"month", "int", "YYYY/MM/DD defaults to 2000/01/01"},
{"day", "int", "YYYY/MM/DD defaults to 2000/01/01"},
{"hour", "int", "hh:mm:ss defaults to 00:00:00"},
{"minute", "int", "hh:mm:ss defaults to 00:00:00"},
{"second", "int", "hh:mm:ss defaults to 00:00:00"}};
}
public void init() {
update = new long[11];
java.net.URL base = getCodeBase();
digits = new Image[10];
for (int i = 0; i <= 9; i++) digits[i] = getImage(base, i + ".gif");
findDate();
try {
switch (getParameter("units").charAt(0)) {
case 's': case 'S': units = 100; sep = getImage(base, "s.gif"); pos = 9; break;
case 'm': case 'M': units = 600; sep = getImage(base, "m.gif"); pos = 8; break;
case 'h': case 'H': units = 360; sep = getImage(base, "h.gif"); pos = 6; break;
case 'd': case 'D': units = 864; sep = getImage(base, "d.gif"); pos = 5; break;
}
} finally {
if (sep == null) sep = getImage(base, "s.gif");
return;
}
}
public void start() {
timer = new Thread(this);
timer.start();
}
public void stop() {
timer.stop();
timer = null;
}
public void run() {
try {
for (;;) {
Thread.sleep(units >> 1);
long diff = System.currentTimeMillis() - y2000 - (units >> 1);
Thread.sleep(diff >= 0 ? units - diff % units : ~diff % units + 1);
fast = true;
repaint();
}
} finally {
return;
}
}
public void paint(Graphics g) {
long diff = System.currentTimeMillis() - y2000;
if (diff < 0) diff = -diff;
diff /= units;
for (int i = 10; i >= 0; i--) {
if (i == pos) g.drawImage(sep, i * 13, 0, this);
else if (fast && update[i] == diff) break;
else {
update[i] = diff;
g.drawImage(digits[(int)(diff % 10)], i * 13, 0, this);
diff /= 10;
}
}
fast = false;
}
public void update(Graphics g) {
paint(g);
}
}

No Frames Version
Customization Page
Back to Millennium Clock Page


644602
38.107.179.230