View unanswered posts | View active topics It is currently Sat May 25, 2013 6:46 am



Reply to topic  [ 2 posts ] 
 Recurrence Rule 
Author Message

Joined: Tue Apr 22, 2008 8:25 pm
Posts: 16
Post Recurrence Rule
Hi, I have a problem with activities. I have been reading the migcalendar documentation about how to create activities for example the third Thursday in the month but I don't understand. I saw that must be used ByXXXRuleData(int field, int[] values, int[] relativeWeekDayInYearOrMonth).
Any idea or example, please ?

This is code of documentation:
relativeWeekDayInYearOrMonth - For Monthly and Yearly frequency rules and a BYDAY (field == Calendar.DAY_OF_WEEK) a relative filter can be set saying for instance "Only first monday of year" or "third to last friday in the month". This is to include support for "1MO" and "-3FR" notations in the BYDAY rule. If this array is non-null it must match the length of values and every element specifies relative order in MONTH/YEAR if not set to 0 in which case that values means "every" as usual.

Thank's !


Tue Jul 29, 2008 5:52 pm
Profile
Site Admin

Joined: Mon Dec 06, 2004 4:24 pm
Posts: 2485
Location: Sweden
Post Re: Recurrence Rule
Hello Henry,

Recurrences are quite tricky. The API in MiG Calendar is rather easy but how to form a specific recurrence will never be since it is a complex thing. You can read RFC 2445 to get an idea on how complex and why the MiG Calendar classes just claim to implement it and doesn't reiterate it (145 pages, http://www.ietf.org/rfc/rfc2445.txt).

This is an example on every third Friday. You can probably start from there.

Code:
RecurrenceRule recurrenceRule = new RecurrenceRule();
recurrenceRule.setFrequency(Calendar.MONTH);

recurrenceRule.addByXXXRule(new ByXXXRuleData(Calendar.DAY_OF_WEEK, new int[] {Calendar.FRIDAY}, new int[] {3}));

//      recurrenceRule.setRepetitionCount(null); // works great
recurrenceRule.setRepetitionCount(10);

DateRange withinRange = new DateRange();
withinRange.addEnd(Calendar.YEAR, 2);
ArrayList list = recurrenceRule.getDateRanges(new DateRange(), withinRange, true);
for (int i = 0; i < list.size(); i++ )
   System.out.println(list.get(i));


Btw, please use the support ticket system to get support.


Thu Jul 31, 2008 11:25 am
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 2 posts ] 

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.