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 715 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.

Stack Programmer
- 3,386
- 1
- 20
- 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.

Hovercraft Full Of Eels
- 283,665
- 25
- 256
- 373