I saw on the Internet that I was supposed to use System.nanoTime() but that doesn\'t work for me - it gives me the time with milliseconds precision. I just need
System.nanoTime()
It may be the case that the underlying OS doesn't provide timers with nanosecond precision.
There is also an older post.