JosephGarrone
JosephGarrone

Reputation: 4161

Get system time accurate to 0.1ms (100 microseconds)

I am trying to conduct some extremely accurate data measurements. For this, I need to be able to get the current time in microseconds, accurate to 100 microseconds (Or more). I can't seem to be able to find any way on the Android Developer website. Device specific answers are acceptable (I have access to a Nexus 7, so any answers involving that would be awesome).

I had originally thought it possible to use the system sensors which give times accurate to the microsecond, however I have no idea how to set and/or tell if the sensors are accurate. Not to mention whether these event. - SensorManager

Is there any way to get the time in microseconds on an android device that is accurate to within 100microseconds?

Upvotes: 3

Views: 3890

Answers (1)

stinepike
stinepike

Reputation: 54692

you can use System.nanoTime(). according to doc

Returns the current timestamp of the most precise timer available on the local system. This timestamp can only be used to measure an elapsed period by comparing it against another timestamp. It cannot be used as a very exact system time expression.

Returns

the current timestamp in nanoseconds.

From the java doc here you will get some extra explanation of it

Upvotes: 5

Related Questions