How can you implement some kind of timer, to know how much time did user spend for one round of a game?
Asked
Active
Viewed 711 times
2 Answers
0
One can easily find the time spent by a user on one round of a game by using System.nanoTime() function. However if you want to implement in a game, you would probably like the timer to also be displayed to the user, you can you use multi-threading for the same.
![](../../users/profiles/81915.webp)
stack programmer
- 3,206
- 1
- 18
- 12
-
Nanoseconds are not only unnecessarily granular, but they are typically inaccurate. Especially when you consider the numerous levels of abstraction between the program being written and the actual clock. – Peaches491 Jun 18 '11 at 20:08
0
Getting System.currentTimeMillis will get your system time to the millisecond. If you want to do a Swing event intermittently, such as displaying the current time in a stop watch or a simple animation, then a Swing Timer would work well.
![](../../users/profiles/522444.webp)
Hovercraft Full Of Eels
- 276,051
- 23
- 238
- 346