Java gives access to two method to get the current time: System.nanoTime()
and System.currentTimeMillis()
. The first one gives a result in nanoseconds, but the actual accuracy is much worse than that (many microseconds).
Is the JVM already providing the best possible value for each particular machine? Otherwise, is there some Java library that can give finer measurement, possibly by being tied to a particular system?
The problem with getting super precise time measurements is that some processors can't/don't provide such tiny increments.
As far as I know, System.currentTimeMillis()
and System.nanoTime()
is the best measurement you will be able to find.
Note that both return a long
value.