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]
# 1
Please help me this is really urgent. All I want to know is if there's a class that will time something for me acturatly - kind of like a stopwatch.
lloneill at 2007-7-7 12:19:56 > top of Java-index,Archived Forums,Java Programming...
# 2

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());

straka at 2007-7-7 12:19:56 > top of Java-index,Archived Forums,Java Programming...
# 3
Thanks a million thats a great help!
lloneill at 2007-7-7 12:19:56 > top of Java-index,Archived Forums,Java Programming...