iCal4J tutorial

sessionEvent.getProperties().add(new Summary("xxxx summary));

 iCal4J is library to generate/parse Calendar ics file.

 

Its simple to use until you know what to do, the docs is not good at all.

 

Here is a few simple steps

 

 

  • 1. Create Calendar object - the big Calendar object matching ics file
  • populate some compulsory fields:
net.fortuna.ical4j.model.Calendar cal = new net.fortuna.ical4j.model.Calendar();
cal.getProperties().add(new ProdId("-//xxx org //iCal4j 1.0//EN"));
cal.getProperties().add(Version.VERSION_2_0);
cal.getProperties().add(CalScale.GREGORIAN);

 

  • Create VEvent Object - which hides all detail about a certain event (including recurring ones)
VEvent sessionEvent = new VEvent();

 

  • Remeber there are lots of object inheriting Property so just create varied properties and add to the event property list
  • For example, create summary for the event

 

sessionEvent.getProperties().add(new Summary("xxxx summary"));
  •  create start time
	String dateAsICal4JString = "20110813T113000"; // date+time format
	sessionEvent.getProperties().add(new DtStart(dateAsICal4JString));
  •  ADD recurring rule
Recur recur = new Recur(Recur.WEEKLY, 20); // 20 is repeat count
recur.getDayList().add(new WeekDay("WE"));
RRule rule = new RRule(recur);
sessionEvent.getProperties().add(rule);
 

 

 

  • At least, add the VEvent created to Calendar component
cal.getComponents().add(sessionEvent);
 

Its very simple right? First time look at it, shit,don't know what to do

 

Here is long code reference where I got the ideas

http://exchangeling.googlecode.com/svn-history/r4/trunk/src/main/java/ExchangeEventConverter/iCal4j.java

 

你可能感兴趣的:(RIA)