groovygarden
Programmer
- Aug 23, 2001
- 63
Hi,
I'm trying to create a timer that will count up from 0 to measure and display the length of time a user has been active - updating in seconds. This is an extract from my code:
If I set minutes and seconds to 00, all that happens is that the system prints out 00:00 at one second intervals. If I don't set them, it prints the correct current time updating at one second intervals.
What am I doing wrong?
Thanks
I'm trying to create a timer that will count up from 0 to measure and display the length of time a user has been active - updating in seconds. This is an extract from my code:
Code:
public void actionPerformed(ActionEvent event)
{
Date today = new Date();;
String result;
SimpleDateFormat formatter = new SimpleDateFormat("mm:ss");
today.setMinutes(00);
today.setSeconds(00);
result = formatter.format(today);
System.out.println("Result: " + result);
If I set minutes and seconds to 00, all that happens is that the system prints out 00:00 at one second intervals. If I don't set them, it prints the correct current time updating at one second intervals.
What am I doing wrong?
Thanks