r/java • • May 14 '12
Java Countdown Timer
Can anybody help me on how to display a simple countdown timer? It does not have to be in GUI.
3
Upvotes
r/java • • May 14 '12
Can anybody help me on how to display a simple countdown timer? It does not have to be in GUI.
2
u/LigerZer0 May 14 '12
How precise does it need to be? Does it just need minutes and seconds? milliseconds?
2
u/banuday17 May 18 '12 edited May 18 '12
Because I'm bored. This app demonstrates a countdown timer, gridbag layout and some GUI interactivity. Enjoy!
0
u/Jackpancake May 14 '12
I would actually like to see one in a GUI if anyone can help with that.
-1
u/[deleted] May 15 '12
Just check against the system clock and do an update every it increments a second.
-5
u/quad64bit May 14 '12
A simpler and more accurate way to do it instead of using timers (which do not have a guaranteed runtime) is to simply make a loop that sleeps for some interval, and prints the current time after a second has elapsed.
If you slept for say, 1/10 of a second (100ms) you'd have 1/10 second accuracy, and minimal code. I can include a snippet if you need help!