System.currentTimeMillis vs System.nanoTime

Accuracy Vs. Precision

What I would like to know is whether I should use System.currentTimeMillis() or System.nanoTime() when updating my object’s positions in my game? Their change in movement is directly proportional to the elapsed time since the last call and I want to be as precise as possible.

I’ve read that there are some serious time-resolution issues between different operating systems (namely that Mac / Linux have an almost 1 ms resolution while Windows has a 50ms resolution??). I’m primarly running my apps on windows and 50ms resolution seems pretty inaccurate.

Are there better options than the two I listed?

Any suggestions / comments?

10 Answers
10

Leave a Comment