How does Calendar.add work around Daylight Savings time?
I'm working on an alarm clock app for Android. I'm doing all of my scheduling and timing using the Calendar
class. I'm curious how Calendar.add
will respond if the current time is before Daylight Savings Time takes effect but the add
will push it to be after DST takes effect.
Specifically:
// 10 mins from DST taking effect
Calendar c = Calendar.getInstance();
c.add(Calendar.MINUTE, 15);
If I schedule a PendingIntent
to broadcast using c.getTimeInMillis()
will the PendingIntent
go off in 15 mins (wall clock time from when the moment you set the AlarmManager
) or will the time change cause it to be in the past or an extra hour in the future?
What can I expect from Calendar.add
when the amount of time being added spans the time that DST takes effect?
下一篇: Calendar.add如何解决夏令时?