use of net.sf.kerner.utils.time.DateConverter in project drbookings by DrBookings.
the class GoogleCalendarSync method clear.
public GoogleCalendarSync clear(final LocalDate date) throws IOException {
final CalendarListEntry flats = getCalendar();
// Iterate over the events in the specified calendar
String pageToken = null;
int cnt = 0;
do {
final Events events;
if (date != null) {
events = client.events().list(flats.getId()).setTimeMin(new DateTime(new DateConverter().convert(date))).setPageToken(pageToken).execute();
} else {
events = client.events().list(flats.getId()).setPageToken(pageToken).execute();
}
final List<Event> items = events.getItems();
for (final Event event : items) {
if (event == null) {
if (logger.isWarnEnabled()) {
logger.warn("Skipping null event");
}
continue;
}
clearEvent(flats.getId(), event);
cnt++;
}
pageToken = events.getNextPageToken();
} while (pageToken != null);
if (logger.isDebugEnabled()) {
logger.debug("Processed " + cnt + " events");
}
return this;
}
Aggregations