I would like to time (and display) how long it takes my program to preform a certain task...
Actually, I have already accomplished this but with one issue:
my timer is displayed in a label 00:00:00
when I start the timer the first second appears like this: 09:00:00
then: 09:00:01
then: 09:00:02
then: 09:00:03
...
...
...
And seems to work fine.
Why is the first second displayed as being 9 hours long? How do I correct this issue?
long count = 0;
private final SimpleDateFormat TIME = new SimpleDateFormat("hh:mm:ss");
Timer stopWatch = new Timer(1000, new ActionListener(){
public void actionPerformed(ActionEvent event){
timerDisplay.setText(TIME.format(new Date(count++ * 1000)));
}
});
Thanks.