In Android, there is a distinction between System.currentTimeMillis()
and SystemClock.elapsedRealTime
.
System.currentTimeMillis() is the standard "wall" clock (time and date) expressing milliseconds since the epoch. The wall clock can be set by the user or the phone network (see setCurrentTimeMillis(long)), so the time may jump backwards or forwards unpredictably.
elapsedRealtime() and elapsedRealtimeNanos() return the time since the system was booted, and include deep sleep.
Can I use Date().timeIntervalSinceNow
to measure elapsed time accurately?
I tried changing the time zone on my iPhone and the default stopwatch changed by many hours, so I'm guessing that the wall clock time is being used.
Does Swift have something equivalent to SystemClock.elapsedRealTime
?