Is System.currentTimeMillis() the best measure of time performance in Java? Are there any gotcha\'s when using this to compare the time before action is taken to the time af
If you need monotonic time measurements, System.nanoTime is a better choice. System.currentTimeMillis is subject to UTC timing variations -- leap seconds, NTP updates and jitter, as well as users setting the system clock*. This can cause some spectacular failures in certain kinds of timing applications. System.nanoTime is supposed to be immune to all that.
The problems with System.nanoTime include periodic numeric overflow and long term timing inaccuracy, making System.currentTimeMillis better for longer time spans (provided that users leave the system clock alone). Note that daylight saving time and time zone changes should not affect System.currentTimeMillis.
*Windows "Sync with internet time" makes stepwise changes. This can be very disruptive, as opposed to a proper NTP client implementation that "chases" the server by adjusting the client timebase frequency.