use of net.fortuna.ical4j.model.CalendarException in project bw-calendar-engine by Bedework.
the class CalendarBuilder method resolveTimezones.
private void resolveTimezones() throws IOException {
// Go through each property and try to resolve the TZID.
for (final Iterator it = datesMissingTimezones.iterator(); it.hasNext(); ) {
final Property property = (Property) it.next();
final Parameter tzParam = property.getParameter(Parameter.TZID);
// tzParam might be null:
if (tzParam == null) {
continue;
}
// lookup timezone
final TimeZone timezone = tzRegistry.getTimeZone(tzParam.getValue());
// If timezone found, then update date property
if (timezone != null) {
// Get the String representation of date(s) as
// we will need this after changing the timezone
final String strDate = property.getValue();
// Change the timezone
if (property instanceof DateProperty) {
((DateProperty) property).setTimeZone(timezone);
} else if (property instanceof DateListProperty) {
((DateListProperty) property).setTimeZone(timezone);
}
// Reset value
try {
property.setValue(strDate);
} catch (ParseException e) {
// shouldn't happen as its already been parsed
throw new CalendarException(e);
} catch (URISyntaxException e) {
// shouldn't happen as its already been parsed
throw new CalendarException(e);
}
}
}
}
Aggregations