我有以下使用双周创建和 ics 字符串的方法:
public String createICalendarString(List<ICalendarEventVo> iCalendarEventVos, String locale, String timeZoneCanonicalId) throws IOException
{
String icsLocale = convertLocaleToIcsFormat(locale);
ICalendar ical = new ICalendar();
for (ICalendarEventVo iCalendarEventVo : iCalendarEventVos)
{
VEvent event = new VEvent();
Summary summary = new Summary(iCalendarEventVo.getSummaryText());
summary.setLanguage(icsLocale);
event.setSummary(summary);
if (null != iCalendarEventVo.getDescriptionText())
{
Description description = new Description(iCalendarEventVo.getDescriptionText());
description.setLanguage(icsLocale);
event.setDescription(description);
}
if (null != iCalendarEventVo.getLocationText())
{
Location location = new Location(iCalendarEventVo.getLocationText());
location.setLanguage(icsLocale);
event.setLocation(location);
}
if (null != iCalendarEventVo.getOrganizerName() && null != iCalendarEventVo.getOrganizerEmail())
{
Organizer organizer = new Organizer(iCalendarEventVo.getOrganizerName(), iCalendarEventVo.getOrganizerEmail());
event.setOrganizer(organizer);
}
event.setDateStart(iCalendarEventVo.getStartDate());
event.setDateEnd(iCalendarEventVo.getEndDate());
event.setUid(iCalendarEventVo.getUid());
ical.addEvent(event);
}
String icsString = null;
try (StringWriter writer = new StringWriter();
ICalWriter icalWriter = new ICalWriter(writer, ICalVersion.V2_0);)
{
//optional: Use Outlook-friendly VTIMEZONE components:
icalWriter.getTimezoneInfo().setGenerator(new TzUrlDotOrgGenerator(true));
//output date/time values in the timeZone that was passed in
TimeZone timeZone = TimeZone.getTimeZone(timeZoneCanonicalId);
icalWriter.getTimezoneInfo().setDefaultTimeZone(timeZone);
icalWriter.write(ical);
icsString = writer.toString();
}
return icsString;
}
生成以下内容:
BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//Michael Angstadt//biweekly 0.4.4//EN
BEGIN:VEVENT
DTSTAMP:20151128T030141Z
SUMMARY;LANGUAGE=en-us:Test ILT Class: Session #1
DESCRIPTION;LANGUAGE=en-us:Test ILT Class goes through what is needed to ma
ke a sale. The session will be about looking nice for your customer.
LOCATION;LANGUAGE=en-us:Statue of Liberty - Meet at the top of the crown.
ORGANIZER;CN=TorchLMS:mailto:no-reply@torchlms.com
DTSTART;TZID=America/New_York:20151201T190000
DTEND;TZID=America/New_York:20151201T220000
UID:TLMS_SESSION_1000110010000000000_1000110210000000051
END:VEVENT
BEGIN:VEVENT
DTSTAMP:20151128T030141Z
SUMMARY;LANGUAGE=en-us:Test ILT Class: Session #2
DESCRIPTION;LANGUAGE=en-us:Test ILT Class goes through what is needed to ma
ke a sale. This session will talk about how to blow sunshine in the direct
ion of the customer.
LOCATION;LANGUAGE=en-us:World Trade Center - Top floor in the penthouse
ORGANIZER;CN=TorchLMS:mailto:no-reply@torchlms.com
DTSTART;TZID=America/New_York:20151202T170000
DTEND;TZID=America/New_York:20151202T190000
UID:TLMS_SESSION_1000110010000000000_1000110210000000101
END:VEVENT
BEGIN:VTIMEZONE
TZID:America/New_York
TZURL:http://tzurl.org/zoneinfo-outlook/America/New_York
X-LIC-LOCATION:America/New_York
BEGIN:DAYLIGHT
TZOFFSETFROM:-0500
TZOFFSETTO:-0400
TZNAME:EDT
DTSTART:19700308T020000
RRULE:FREQ=YEARLY;BYDAY=2SU;BYMONTH=3
END:DAYLIGHT
BEGIN:STANDARD
TZOFFSETFROM:-0400
TZOFFSETTO:-0500
TZNAME:EST
DTSTART:19701101T020000
RRULE:FREQ=YEARLY;BYDAY=1SU;BYMONTH=11
END:STANDARD
END:VTIMEZONE
END:VCALENDAR
问题是当我通过电子邮件将其发送到我的 gmail 帐户时,仅显示第一个事件。起初我认为这是 Biweekly 的问题,但看起来 ics 输出是正确的。ics输出有问题吗?