0

Alarms in my application fire off 8 hours after the time I set in Calendar.HOUR_OF_DAY. My time zone is UTC +8. Could you please help me to make the alarms fire off exactly as the time I select using a TimePicker, and also to make it flexible for other time zones. Thank you

 Ev_calendar.set(Calendar.HOUR_OF_DAY,xxx3);
 Ev_calendar.set(Calendar.MINUTE, xxx4);
 Ev_calendar.set(Calendar.SECOND, 0);
 long Evening_TimeInMillis=Ev_calendar.getTimeInMillis();
    mAlarmManager.setRepeating(AlarmManager.RTC_WAKEUP,
                  Evening_TimeInMillis,AlarmManager.INTERVAL_DAY,Evening_pi); 
Me. Moh
  • 1
  • 3
  • Which OS version are you testing your Alarm? – Sagar Jun 24 '18 at 03:03
  • Convert the time you get from the TimePicker to UTC and then set the alarm by the converted time. – fatemeh fallahi arezoudar Jun 24 '18 at 03:40
  • thank you sagar ... I am using Windows 7 – Me. Moh Jun 24 '18 at 04:49
  • Thank you fatemeh fallahi arezoudar... could you please give me some idea on how to successfully convert it... i am new to android programming... your help is highly appreciated – Me. Moh Jun 24 '18 at 04:52
  • 1
    What does `Ev_calendar.getTimezone().getID()` return? – Matt Johnson-Pint Jun 24 '18 at 18:48
  • 1
    It will be easier and give more natural code if you upgrade to [`java.time`, the modern Java date and time API](https://docs.oracle.com/javase/tutorial/datetime/). The `Calendar` class is long outdated and poorly designed and `java.time` so much nicer to work with. Yes, you can use it on Android. For older Android see [How to use ThreeTenABP in Android Project](https://stackoverflow.com/questions/38922754/how-to-use-threetenabp-in-android-project). – Ole V.V. Jun 25 '18 at 09:59
  • 1
    Ev_calendar.getTimezone().getID() returns GMT – Me. Moh Jun 25 '18 at 16:58

0 Answers0