If I understand correctly, System.currentTimeMillis() is faster, and System.nanoTime() is more accurate.
If I am pinging a server, which in worst case I expect to take...lets go extreme...one minute, is System.currentTimeMillis() still going to be accurate within 1-2 milliseconds? Or should I go with System.nanoTime()?
I am pinging the server like so:
long startTime = System.nanoTime();
getResponseFromServer();
long endTime = System.nanoTime();
return endTime - startTime;
As you can see, I am currently using System.nanoTime(), but am unsure if I should be using System.currentTimeMillis().
System.currentTimeMillis vs System.nanoTime has a lot of great information on the subject, but not specifics on accuracy of System.currentTimeMillis().