return calendar;
}
public static void addToCalendar(Calendar calendar, Event event) {
DateTime beginDate = new DateTime(event.getBeginDate().getTime());
beginDate.setTimeZone(JST_TIMEZONE);
VEvent vEvent;
if (event.getEndDate() != null) {
DateTime endDate = new DateTime(event.getEndDate().getTime());
endDate.setTimeZone(JST_TIMEZONE);
vEvent = new VEvent(beginDate, endDate, event.getTitle());
} else {
vEvent = new VEvent(beginDate, event.getTitle());
}
// set unique identifier
vEvent.getProperties().add(new Uid(event.getId()));
// Description
vEvent.getProperties().add(new Description(event.getEventURL()));
// URL
if (event.getUrl() != null && !event.getUrl().isEmpty()) {
try {
vEvent.getProperties().add(new Url(new URI(event.getUrl())));
} catch (URISyntaxException e) {
e.printStackTrace();
}
}
// modified
DateTime modifiedAt = null;
if (event.getModifiedAt() != null) {
modifiedAt = new DateTime(event.getModifiedAt().getTime());
} else if (event.getCreatedAt() != null){
modifiedAt = new DateTime(event.getCreatedAt().getTime());
}
if (modifiedAt != null) {
modifiedAt.setTimeZone(JST_TIMEZONE);
vEvent.getProperties().add(new LastModified(modifiedAt));
}
// sequence
vEvent.getProperties().add(new Sequence(event.getRevision()));