You'll need to do some appropriate rounding using the Math.floor method,
and also think about adding leading zeros if the numbers are smaller than 10.
If you're feeling adventurous, you might also have a look at the java.text.SimpleDateFormat class
I would also slow the timer way down. What good is having it fire every millisecond if the display only cares about seconds? That takes up too many CPU cycles accomplishing nothing.
why this is not working?
As an aside, a more accurate way to determine time passed would be to store System.currentTimeMillis() when the timer starts, and then to get it again on each iteration in the actionPerformed method, and to subtract the start time. By counting in your own code you're relying on the timer running exactly every 100ms, which is unlikely to be the case.
Cannot invoke getTime(long) on the primitive type long
Did you see how Paul cut 87% off of his electric heat bill with 82 watts of micro heaters? |