我正在尝试使用ical4j创建和保存ics
当我运行下面的代码时,我得到一个日历必须包含至少一个组件。如何将组件附加到日历,或将事件附加到日历…
线程"main"异常。ValidationException: Calendar必须包含至少一个组件
Calendar calendar = new Calendar();
calendar.getProperties().add(new ProdId("-//Tyler Eans//iCal4j 1.0//EN"));
calendar.getProperties().add(Version.VERSION_2_0);
calendar.getProperties().add(CalScale.GREGORIAN);
java.util.Calendar cal = java.util.Calendar.getInstance();
cal.set(java.util.Calendar.MONTH, java.util.Calendar.DECEMBER);
cal.set(java.util.Calendar.DAY_OF_MONTH, 25);
VEvent christmas = new VEvent(new Date(cal.getTime()), "Christmas Day");
// initialise as an all-day event..
christmas.getProperties().getProperty(Property.DTSTART).getParameters().add(Value.DATE);
FileOutputStream fout = new FileOutputStream("mycalendar.ics");
CalendarOutputter outputter = new CalendarOutputter();
outputter.output(calendar, fout);
在输出前添加这一行:
calendar.getComponents().add(christmas);