timer class
hi, i want to build an application that allows me to accuratly time a games on snooker tables. the user will click on a button to start the timer. it will take the time from the system and monitor it until it has been manually stopped by the user. it will then calculate how long the user has been using the table. I am looking for through the class libraries for a class to use to do the actual timing, has anyone any ideas please!
thank you
[455 byte] By [
lloneill] at [2007-9-27 22:11:49]

That you can do is :
1, store actual time when the buton is pressed first time
2, store actual time when the buton is pressed second time
3, compute the duration
class Timer {
public long starttime;
public long endtime;
public firstPush() {
starttime = System.currentTimeMillis();
}
public secondPush() {
endtime = System.currentTimeMillis();
}
public java.util.Date getDuration() {
return new java.util.Date(endtime - starttime);
}
}
and use it
Timer timer = new Timer.
...
timer.firstPush();
.....
timer.secondPush();
....
System.out.println("The time is " + timer.getDuration());