How to handle Events.RRULE

I have a calendar view where I set events, but I have no idea how to handle recurring events. I get the value of Event.RRULE with the cursor:

String rrule = cursor.getString(cursor.getColumnIndex(Events.RRULE)); 

For example, the value of rrule:

 FREQ=WEEKLY;BYDAY=MO,WE,FR;INTERVAL=1 FREQ=MONTHLY;BYMONTHDAY=6;INTERVAL=2 

How do I get the values ​​from this row to set them as calendar values?

For example, I want to get Monday - MO to set it in a Calendar object

 Calendar c = Calendar.getInstance(); c.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY); 
+6
source share
1 answer

There are different libraries for handling RRULE. You can use google-rfc-2445

 import com.google.ical.values.RRule; //... RRule rule = new RRule("RRULE:FREQ=MONTHLY;BYMONTHDAY=6;INTERVAL=2"); 

and use useful properties for the created object, or you can use lib-recur

 import org.dmfs.rfc5545.recur.RecurrenceRule; // ... RecurrenceRule rule = new RecurrenceRule("FREQ=MONTHLY;BYMONTHDAY=6;INTERVAL=2"); 

and use the analyzed properties from the rule object.

+2
source

Source: https://habr.com/ru/post/1014780/


All Articles