I would like to measure elapsed time in a Java. However differences in `System.currentTimeMillis()` and (I believe) `System.nanoTime()` can be changed by external changes eg someone (or the system) altering the system clock.

Using network calls is not an option as it's possible very frequent and fast returns are required.

Is there a common solution for this?

**EDIT**

Sorry, I should have elaborated about the reason. It isn't to stop malicious users - it's things like client initiated logout for being idle and routine client events.