aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/model/Calendar.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/org/traccar/model/Calendar.java')
-rw-r--r--src/main/java/org/traccar/model/Calendar.java15
1 files changed, 6 insertions, 9 deletions
diff --git a/src/main/java/org/traccar/model/Calendar.java b/src/main/java/org/traccar/model/Calendar.java
index 56d3eb74c..2476efa0a 100644
--- a/src/main/java/org/traccar/model/Calendar.java
+++ b/src/main/java/org/traccar/model/Calendar.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016 Anton Tananaev (anton@traccar.org)
+ * Copyright 2016 - 2021 Anton Tananaev (anton@traccar.org)
* Copyright 2016 Andrey Kunitsyn (andrey@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -18,6 +18,7 @@ package org.traccar.model;
import java.io.ByteArrayInputStream;
import java.io.IOException;
+import java.time.Duration;
import java.util.Collection;
import java.util.Date;
@@ -28,10 +29,9 @@ import net.fortuna.ical4j.data.ParserException;
import net.fortuna.ical4j.filter.Filter;
import net.fortuna.ical4j.filter.PeriodRule;
import net.fortuna.ical4j.model.DateTime;
-import net.fortuna.ical4j.model.Dur;
import net.fortuna.ical4j.model.Period;
+import net.fortuna.ical4j.model.TimeZoneRegistryImpl;
import net.fortuna.ical4j.model.component.CalendarComponent;
-import org.apache.commons.collections4.Predicate;
import org.traccar.database.QueryIgnore;
public class Calendar extends ExtendedModel {
@@ -68,13 +68,10 @@ public class Calendar extends ExtendedModel {
public boolean checkMoment(Date date) {
if (calendar != null) {
- Period period = new Period(new DateTime(date), new Dur(0, 0, 0, 0));
- Predicate<CalendarComponent> periodRule = new PeriodRule<>(period);
- Filter<CalendarComponent> filter = new Filter<>(new Predicate[] {periodRule}, Filter.MATCH_ANY);
+ Period period = new Period(new DateTime(date), Duration.ZERO);
+ Filter<CalendarComponent> filter = new Filter<>(new PeriodRule<>(period));
Collection<CalendarComponent> events = filter.filter(calendar.getComponents(CalendarComponent.VEVENT));
- if (events != null && !events.isEmpty()) {
- return true;
- }
+ return events != null && !events.isEmpty();
}
return false;
}