I have calendar view where I'm setting events but I don't have idea how to handle with recurring events. I'm getting value of Event.RRULE by cursor:
String rrule = cursor.getString(cursor.getColumnIndex(Events.RRULE));
For example rrule value is:
FREQ=WEEKLY;BYDAY=MO,WE,FR;INTERVAL=1
FREQ=MONTHLY;BYMONTHDAY=6;INTERVAL=2
How can I get values from this string to set them as Calendar values?
For example I want get Monday - MO to set it in Calendar object
Calendar c = Calendar.getInstance();
c.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
There are different libraries to handle RRULEs. You can use google-rfc-2445
import com.google.ical.values.RRule;
//...
RRule rule = new RRule("RRULE:FREQ=MONTHLY;BYMONTHDAY=6;INTERVAL=2");
and than use properties for created object in useful way, or you could use lib-recur
import org.dmfs.rfc5545.recur.RecurrenceRule;
// ...
RecurrenceRule rule = new RecurrenceRule("FREQ=MONTHLY;BYMONTHDAY=6;INTERVAL=2");
and use parsed properties from rule
object.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With