Reputation: 1678
How can I get Time in Millisecond from Calendar Object in order to set an interval in Alarm Manager I am using the following code:
am.setRepeating(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), interval, sender);
and my calculation for interval
for getting One month of MilliSeconds is as follows:
Calendar monthCal = Calendar.getInstance();
monthCal.clear();
monthCal.setTimeInMillis(System.currentTimeMillis());
monthCal.add(Calendar.MONTH, 1);
interval = monthCal.getTimeInMillis();
but I am not getting any repeating Alarms.
Upvotes: 0
Views: 996
Reputation: 31846
You can do the following:
Calendar c = Calendar.getInstance();
c.set(year,month,1); // Set the year and month you want milliseconds for
long daysInMonth = c.getActualMaximum(Calendar.DATE); //Get how many days this month have
long millisInMonth = daysInMonth*dayMillis; //Multiply the amount of days with how many milliseconds a day consists of (86400000L)
Upvotes: 1