Question: Will a Timer on Android scheduled to execute every second work during a leap second?

Question

Will a Timer on Android scheduled to execute every second work during a leap second?

Answers 1
Added at 2016-12-31 17:12
Tags
Question

Supposing I have a timer running in an Activity on Android (say, Android 6.0, in case it matters).

Timer timer = new Timer();
timer.schedule(timerTask, 0, 1000);

Will this run during each and every second during midnight on the evening of a leap second?

23:59:58
23:59:59
23:59:60
00:00:00

Or will nothing be scheduled to run during the leap second?

Answers
nr: #1 dodano: 2016-12-31 17:12

AFAIK, from Android's standpoint, there is no leap second.

The concept of a leap second is enforced, such as it is, by atomic clocks and other official time sources. Individual Android devices do not have some logic in them to say "well, hey, if this bunch of scientists called for a leap second, we'll add one".

The next time sync after the leap second — SNTP, NITZ, or whatever the device is using for time sync — will correct the time to reflect the leap second, just as it would correct the time for any other form of clock drift. And, if the device is not syncing its time, because the user manually specified the time, the device is unaffected by leap seconds.

Beyond that, things like Timer are working on elapsed time (e.g., 1000 milliseconds from now), which also is unaffected by leap seconds, time syncs, etc.

Source Show
◀ Wstecz