I’m developing a system that often use the system time because the Delayed
interface.
What is fastet way to get the time from system?
Currently I’m using Calendar.getInstance().getTimeInMillis()
every time I need to get the time, but I don’t know if there is a faster way.
Advertisement
Answer
System.currentTimeMillis()
“Returns the current time in milliseconds”.
Use this to get the actual system time.
System.nanoTime()
.
“The value returned represents nanoseconds since some fixed but arbitrary origin time”
Use this is you’re measuring time lapses / events.