Search code examples
androidtimezonealarmmanagerdst

Android AlarmManager and DST/Timezone/Time change?


I'm coding an alarm clock application, and i would like to know what happens, when I set some alarm with AlarmManager for example at time 2:59am (this is not time of my alarm, this is only time WHEN i set some alarm), and at 3:00am there will be automatic time change from summer time to winter (DST). What happens with my scheduled alarm? I found nothing in docs, and it's not so easy to test, at least I must change dates and wait few hours...I'm not so patient ;)

Next problem - I was also curious, what happens with my alarms set with AlarmManager when user changes timezone. This was luckily pretty easy to test, and I found, that android is pretty "intelligent" and reschedule alarm automatically. So when in my timezone is for example 9:00 and i set alarm on 10:00, and switch timezone (+1 hours) where actual time is 10:00, android reschedule my alarm to 11:00, as expected. This is very fine, however, i didn't found also anything in docs...

Anybody has more official information? Thx


Solution

  • RTC and RTC_WAKEUP use System.currentTimeMillis() as the timebase, which is in UTC time and therefore is independent of time zone changes, daylight savings time changes, etc.