diff --git a/src/main/java/org/olat/commons/calendar/CalendarModule.java b/src/main/java/org/olat/commons/calendar/CalendarModule.java index 2ca2eb8a45cb53bdfa488cc2dd69204a804d3f29..bd8c4200a10cf7e5b24dcb872b44941fe677d1d1 100644 --- a/src/main/java/org/olat/commons/calendar/CalendarModule.java +++ b/src/main/java/org/olat/commons/calendar/CalendarModule.java @@ -26,6 +26,8 @@ import net.fortuna.ical4j.util.CompatibilityHints; import org.olat.core.configuration.AbstractOLATModule; import org.olat.core.configuration.PersistedProperties; +import org.olat.core.logging.OLog; +import org.olat.core.logging.Tracing; /** * @@ -38,6 +40,8 @@ import org.olat.core.configuration.PersistedProperties; */ public class CalendarModule extends AbstractOLATModule { + private static final OLog log = Tracing.createLoggerFor(CalendarModule.class); + private TimeZone defaultTimeZone; private TimeZoneRegistry timeZoneRegistry; @@ -48,8 +52,12 @@ public class CalendarModule extends AbstractOLATModule { System.setProperty(CompatibilityHints.KEY_RELAXED_UNFOLDING, "true"); System.setProperty(CompatibilityHints.KEY_RELAXED_PARSING, "true"); String defaultTimeZoneID = java.util.TimeZone.getDefault().getID(); + log.info("Calendar time zone: " + defaultTimeZoneID); timeZoneRegistry = TimeZoneRegistryFactory.getInstance().createRegistry(); defaultTimeZone = timeZoneRegistry.getTimeZone(defaultTimeZoneID); + if(defaultTimeZone == null) { + log.error("Cannot match the JVM default time zone to an ical4j time zone: " + defaultTimeZoneID); + } } @Override diff --git a/src/main/java/org/olat/commons/calendar/CalendarUtils.java b/src/main/java/org/olat/commons/calendar/CalendarUtils.java index b4fcab6e81ae305f135e149954116084824a017c..5429729ef5f886face7d5666f34ef64c93b45633 100644 --- a/src/main/java/org/olat/commons/calendar/CalendarUtils.java +++ b/src/main/java/org/olat/commons/calendar/CalendarUtils.java @@ -205,7 +205,9 @@ public class CalendarUtils { Date dUntil = recur.getUntil(); DateTime dtUntil = dUntil == null ? null : new DateTime(dUntil.getTime()); if(dtUntil != null) { - dtUntil.setTimeZone(tz); + if(tz != null) { + dtUntil.setTimeZone(tz); + } return dtUntil; } } catch (ParseException e) { @@ -245,7 +247,9 @@ public class CalendarUtils { } if(recurrenceEnd != null) { DateTime recurEndDT = new DateTime(recurrenceEnd.getTime()); - recurEndDT.setTimeZone(tz); + if(tz != null) { + recurEndDT.setTimeZone(tz); + } sb.append(";"); sb.append(KalendarEvent.UNTIL); sb.append("="); diff --git a/src/main/java/org/olat/commons/calendar/ICalFileCalendarManager.java b/src/main/java/org/olat/commons/calendar/ICalFileCalendarManager.java index 77e7f79c65ee3a75ee59bcce248bb969adf4e661..f871b358928c99dbf4c8c23c0b034604dbde8523 100644 --- a/src/main/java/org/olat/commons/calendar/ICalFileCalendarManager.java +++ b/src/main/java/org/olat/commons/calendar/ICalFileCalendarManager.java @@ -63,7 +63,6 @@ import net.fortuna.ical4j.model.property.CalScale; import net.fortuna.ical4j.model.property.Clazz; import net.fortuna.ical4j.model.property.Contact; import net.fortuna.ical4j.model.property.Created; -import net.fortuna.ical4j.model.property.DtEnd; import net.fortuna.ical4j.model.property.Duration; import net.fortuna.ical4j.model.property.ExDate; import net.fortuna.ical4j.model.property.LastModified; @@ -353,9 +352,13 @@ public class ICalFileCalendarManager extends BasicManager implements CalendarMan if (!kEvent.isAllDayEvent()) { // regular VEvent DateTime dtBegin = new DateTime(kEvent.getBegin()); - dtBegin.setTimeZone(tz); + if(tz != null) { + dtBegin.setTimeZone(tz); + } DateTime dtEnd = new DateTime(kEvent.getEnd()); - dtEnd.setTimeZone(tz); + if(tz != null) { + dtEnd.setTimeZone(tz); + } vEvent = new VEvent(dtBegin, dtEnd, kEvent.getSubject()); } else { // AllDay VEvent @@ -707,7 +710,11 @@ public class ICalFileCalendarManager extends BasicManager implements CalendarMan java.util.Calendar recurStartCal = java.util.Calendar.getInstance(); recurStartCal.clear(); - recurStartCal.setTimeInMillis(date.getTime()-tz.getOffset(date.getTime())); + if(tz == null) { + recurStartCal.setTimeInMillis(date.getTime()); + } else { + recurStartCal.setTimeInMillis(date.getTime() - tz.getOffset(date.getTime())); + } long duration = kEvent.getEnd().getTime() - kEvent.getBegin().getTime(); java.util.Calendar beginCal = java.util.Calendar.getInstance();