0
Calendar calendar = Calendar.getInstance(TimeZone
                .getTimeZone("GMT"));

This is how I am setting my timezone to GMT for alarm purpose and setting the alarm according to GMT. Now is there any auto configuration way in android by which the alarm time will be set to according to its timezone ? if there is no auto configuration for this purpose then can anyone suggest me any idea ?

1 Answers1

0

Please read the dst/tz best practices, and the timezone tag wiki.

In particular, you should not schedule a future event (such as an alarm) by GMT. You should set an alarm based on local time - either for a specific time zone, or for whatever the system time zone happens to be.

Typically on a mobile device, you would not bind an alarm to anything but the system local time zone. For example, if a user has a phone with a daily alarm set to 8:00 AM every day, then even if the user travels with their phone to a different time zone, the alarm would still go off at 8:00 am - even though that's a different point in GMT/UTC than was originally scheduled. This is how all modern smartphones work.

Anyone that tells you "always use UTC/GMT" has not thought about scheduling.

Community
  • 1
  • 1
Matt Johnson-Pint
  • 230,703
  • 74
  • 448
  • 575
  • But image a scenario where an event starts at 8:00AM according to my timezone but it will start at a very different time in a different time zone. Now I set the alarm or notification in my app according to my timezone will it automatically adjust itself to the different timezone? To adjust itself in a different timezone the alarm time will have to be automatically changed because for an example the 8:00AM can be equivalent to 11:00PM in that time. Think about a TV show. – salehin khan Apr 30 '17 at 17:19
  • In the case of a specific event in a particular place, you would track a local time, the time zone, and whatever recurrence rule is applicable. For example, `08:00`, `America/Los_Angeles`, `Daily`. Sometimes this will be `16:00 UTC`, and sometimes it will be `15:00 UTC`, depending on whether DST is in effect in US Pacific time. In another time zone, that could translate to even 3 different local times (depending on DST for *that* time zone). However - for alarms local to the device (such as an alarm clock app on a phone), a time zone should not be recorded at all. – Matt Johnson-Pint May 01 '17 at 10:16