iCal4J tutorial

本文详细介绍了如何利用iCal4J库创建和管理日历事件,包括创建Calendar对象、VEvent对象,设置事件详情如开始时间、规则等步骤。教程从基础入手,逐步引导读者完成复杂操作。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值