Wil Ferraciolli
Wil Ferraciolli

Reputation: 477

Recurrence rule until using iCal4J

I am working on a project and need to generate recurrences for a date range using iCal4J library. Basically it is a simple RRule to repeat weekly, every friday for the duration of six months.

This is what I have:

Recur recur = new Recur("FREQ=WEEKLY;INTERVAL=1;BYDAY=FR;WKST=MO;UNTIL=20170428T003000Z;");

 DateTime startDate = new DateTime("20160727T0030000Z");
 Date endDate = recur.getUntil();
 DateTime baseDate = new DateTime("20160727T003000Z");
DateList dateList = recur.getDates(baseDate, startDate, endDate, Value.DATE_TIME);

This generates weekly meetings every friday at half midnight, however the last meeting should be on the 27/01/2017 but instead it is 20/01/2017.

One meeting gets taken out. Ps this only occurs within this date range (maybe something to do with Britsh Summer Time BST), however it is set to be UTC therefore it should not matter right?

Then if I change the UNTIL property from the recurrence rule to be 21-01-2017 at 23:59:59 then it gets picked up.

Any suggestions?

Regards

Upvotes: 0

Views: 1898

Answers (1)

Riddhi Gohil
Riddhi Gohil

Reputation: 1818

Try it out : Here is an example for my recurrence rule for same.

If my start date is 10/08/2016 and date is 10/12/2016 then this will create recurring dates for all friday coming between these two dates.

Weekly Recurrence Rule is

RRULE:FREQ=WEEKLY;BYDAY=FR;INTERVAL=1;UNTIL=20161218T000000Z
RRULE:FREQ=WEEKLY;BYDAY=<Day of week>;INTERVAL=<Every month/with some interval>;UNTIL=<Until Date>

So as per this your rule will be like : "RRULE:FREQ=WEEKLY;BYDAY=FR;INTERVAL=1;UNTIL=20170428T003000Z"

Upvotes: 1

Related Questions