我应该如何使用 iCal4j 将会议组织者添加到 iCal 事件
How should I use iCal4j to add a meeting organizer to an iCal event
这就是我成功创建活动的方式,但我无法成功编写组织者添加代码:
//Creating a new calendar
net.fortuna.ical4j.model.Calendar calendar = new net.fortuna.ical4j.model.Calendar();
calendar.getProperties().add(new ProdId("-//Ben Fortuna//iCal4j 1.0//EN"));
calendar.getProperties().add(Version.VERSION_2_0);
calendar.getProperties().add(CalScale.GREGORIAN);
TimeZoneRegistry registry = TimeZoneRegistryFactory.getInstance().createRegistry();
TimeZone timezone = registry.getTimeZone("Etc/GMT");
//Creating an event
java.util.Calendar startCal = java.util.Calendar.getInstance(timezone);
startCal.set(java.util.Calendar.YEAR, 2005);
startCal.set(java.util.Calendar.MONTH, java.util.Calendar.NOVEMBER);
startCal.set(java.util.Calendar.DAY_OF_MONTH, 1);
startCal.set(java.util.Calendar.HOUR_OF_DAY, 15);
startCal.clear(java.util.Calendar.MINUTE);
startCal.clear(java.util.Calendar.SECOND);
java.util.Calendar endCal = java.util.Calendar.getInstance(timezone);
endCal.set(java.util.Calendar.YEAR, 2005);
endCal.set(java.util.Calendar.MONTH, java.util.Calendar.NOVEMBER);
endCal.set(java.util.Calendar.DAY_OF_MONTH, 1);
endCal.set(java.util.Calendar.HOUR_OF_DAY, 19);
endCal.clear(java.util.Calendar.MINUTE);
endCal.clear(java.util.Calendar.SECOND);
net.fortuna.ical4j.model.DateTime dtStart = new DateTime (startCal.getTime());
dtStart.setUtc(true);
net.fortuna.ical4j.model.DateTime dtEnd = new DateTime (endCal.getTime());
dtEnd.setUtc(true);
VEvent event = new VEvent(dtStart,dtEnd, "Test Event");
您将使用以下代码行
event.getProperties().add(new Organizer("mailto:bob@example.com"));
如果需要更大的灵活性,您还可以:
event.getProperties().add(new Organizer());
event.getProperties().getProperty(Property.ORGANIZER).setValue("MAILTO:bob@example.com");
event.getProperties().getProperty(Property.ORGANIZER).getParameters().add(new Cn("Bob Boby"));
这就是我成功创建活动的方式,但我无法成功编写组织者添加代码:
//Creating a new calendar
net.fortuna.ical4j.model.Calendar calendar = new net.fortuna.ical4j.model.Calendar();
calendar.getProperties().add(new ProdId("-//Ben Fortuna//iCal4j 1.0//EN"));
calendar.getProperties().add(Version.VERSION_2_0);
calendar.getProperties().add(CalScale.GREGORIAN);
TimeZoneRegistry registry = TimeZoneRegistryFactory.getInstance().createRegistry();
TimeZone timezone = registry.getTimeZone("Etc/GMT");
//Creating an event
java.util.Calendar startCal = java.util.Calendar.getInstance(timezone);
startCal.set(java.util.Calendar.YEAR, 2005);
startCal.set(java.util.Calendar.MONTH, java.util.Calendar.NOVEMBER);
startCal.set(java.util.Calendar.DAY_OF_MONTH, 1);
startCal.set(java.util.Calendar.HOUR_OF_DAY, 15);
startCal.clear(java.util.Calendar.MINUTE);
startCal.clear(java.util.Calendar.SECOND);
java.util.Calendar endCal = java.util.Calendar.getInstance(timezone);
endCal.set(java.util.Calendar.YEAR, 2005);
endCal.set(java.util.Calendar.MONTH, java.util.Calendar.NOVEMBER);
endCal.set(java.util.Calendar.DAY_OF_MONTH, 1);
endCal.set(java.util.Calendar.HOUR_OF_DAY, 19);
endCal.clear(java.util.Calendar.MINUTE);
endCal.clear(java.util.Calendar.SECOND);
net.fortuna.ical4j.model.DateTime dtStart = new DateTime (startCal.getTime());
dtStart.setUtc(true);
net.fortuna.ical4j.model.DateTime dtEnd = new DateTime (endCal.getTime());
dtEnd.setUtc(true);
VEvent event = new VEvent(dtStart,dtEnd, "Test Event");
您将使用以下代码行
event.getProperties().add(new Organizer("mailto:bob@example.com"));
如果需要更大的灵活性,您还可以:
event.getProperties().add(new Organizer());
event.getProperties().getProperty(Property.ORGANIZER).setValue("MAILTO:bob@example.com");
event.getProperties().getProperty(Property.ORGANIZER).getParameters().add(new Cn("Bob Boby"));