I'm trying to create an .ics file using ICal4j.
But when I try to add a recurrence it fails, throwing a ValidationException:
net.fortuna.ical4j.model.ValidationException: Invalid property: RRULE at
net.fortuna.ical4j.model.Calendar.validate(Calendar.java:297) at
net.fortuna.ical4j.model.Calendar.validate(Calendar.java:257) at
net.fortuna.ical4j.data.CalendarOutputter.output(CalendarOutputter.java:96) at
net.fortuna.ical4j.data.CalendarOutputter.output(CalendarOutputter.java:83)
My code to add the recurrence is:
Recur recur = new Recur(Recur.WEEKLY,null);
recur.setUntil( new DateTime(dateTo.getTime()) );
RRule rule = new RRule(recur);
cal.getProperties().add(rule);
Without this rule it works fine, but I want to add this event every monday
until 12 December 2011 (the date returned by dateTo). Any ideas?
I had similar problem with this API. Unfortunately I do not have the code right now but I remember that problem was that some properties are "optional". There is an API that allows their registration. I'd recommend you to download the source code and check out what does method
validatedo. You will see that it verifies that the property is in collection (or map). Then just find that method that adds properties to this collection.If you have troubles with achieving the source code just decompile the class files. I personally did this with this package. I used plugin to eclipse that decompiles every class that does not have associated source code: http://java.decompiler.free.fr/?q=jdeclipse
I am sorry that my answer is not concrete enough but I hope it is helpful anyway. Good luck.