From f16f5d784f92775134ea535b2ea46d757f7b351e Mon Sep 17 00:00:00 2001 From: Ben Fortuna Date: Sun, 5 Jul 2020 09:38:10 +1000 Subject: [PATCH] Fixed date formatting --- src/main/java/net/fortuna/ical4j/model/Period.java | 5 +---- src/main/java/net/fortuna/ical4j/model/PeriodList.java | 6 +++--- .../java/net/fortuna/ical4j/model/property/FreeBusy.java | 6 +++--- .../net/fortuna/ical4j/model/component/VFreeBusyTest.java | 6 +++--- 4 files changed, 10 insertions(+), 13 deletions(-) diff --git a/src/main/java/net/fortuna/ical4j/model/Period.java b/src/main/java/net/fortuna/ical4j/model/Period.java index b57c0b1e5..adb295241 100644 --- a/src/main/java/net/fortuna/ical4j/model/Period.java +++ b/src/main/java/net/fortuna/ical4j/model/Period.java @@ -44,9 +44,6 @@ import java.util.Date; import java.util.*; -import org.apache.commons.lang3.builder.EqualsBuilder; -import org.apache.commons.lang3.builder.HashCodeBuilder; - /** * $Id$ [Apr 14, 2004] * @@ -363,7 +360,7 @@ public final PeriodList subtract(final Period period) { Interval thatInterval = TemporalAdapter.isFloating(getStart()) ? period.toInterval(ZoneId.systemDefault()) : period.toInterval(); if (thatInterval.encloses(thisInterval)) { - return new PeriodList<>(); + return new PeriodList<>(period.dateFormat); } else if (thatInterval.overlaps(thisInterval)) { return new PeriodList<>(Collections.singletonList(this)); } diff --git a/src/main/java/net/fortuna/ical4j/model/PeriodList.java b/src/main/java/net/fortuna/ical4j/model/PeriodList.java index fa2c7e2d5..81bfd579c 100644 --- a/src/main/java/net/fortuna/ical4j/model/PeriodList.java +++ b/src/main/java/net/fortuna/ical4j/model/PeriodList.java @@ -151,7 +151,7 @@ public final boolean remove(final Object period) { public final PeriodList normalise() { Period prevPeriod = null; Period period; - final PeriodList newList = new PeriodList<>(); + final PeriodList newList = new PeriodList<>(dateFormat); boolean normalised = false; for (Period period1 : periods) { period = period1; @@ -208,7 +208,7 @@ public final PeriodList normalise() { */ public final PeriodList add(final PeriodList periods) { if (periods != null) { - final PeriodList newList = new PeriodList<>(); + final PeriodList newList = new PeriodList<>(dateFormat); newList.getPeriods().addAll(this.periods); newList.getPeriods().addAll(this.periods); return newList.normalise(); @@ -231,7 +231,7 @@ public final PeriodList subtract(final PeriodList subtractions) { } PeriodList result = this; - PeriodList tmpResult = new PeriodList<>(); + PeriodList tmpResult = new PeriodList<>(dateFormat); for (final Period subtraction : subtractions.getPeriods()) { for (final Period period : result.getPeriods()) { diff --git a/src/main/java/net/fortuna/ical4j/model/property/FreeBusy.java b/src/main/java/net/fortuna/ical4j/model/property/FreeBusy.java index 3b8eb8491..a85b3b6be 100644 --- a/src/main/java/net/fortuna/ical4j/model/property/FreeBusy.java +++ b/src/main/java/net/fortuna/ical4j/model/property/FreeBusy.java @@ -115,7 +115,7 @@ public class FreeBusy extends Property { */ public FreeBusy() { super(FREEBUSY); - periods = new PeriodList<>(); + periods = new PeriodList<>(CalendarDateFormat.UTC_DATE_TIME_FORMAT); } /** @@ -140,7 +140,7 @@ public FreeBusy(final ParameterList aList, final String aValue) { */ public FreeBusy(final List> pList) { super(FREEBUSY); - periods = new PeriodList<>(pList); + periods = new PeriodList<>(pList, CalendarDateFormat.UTC_DATE_TIME_FORMAT); } /** @@ -149,7 +149,7 @@ public FreeBusy(final List> pList) { */ public FreeBusy(final ParameterList aList, final List> pList) { super(FREEBUSY, aList); - periods = new PeriodList<>(pList); + periods = new PeriodList<>(pList, CalendarDateFormat.UTC_DATE_TIME_FORMAT); } /** diff --git a/src/test/java/net/fortuna/ical4j/model/component/VFreeBusyTest.java b/src/test/java/net/fortuna/ical4j/model/component/VFreeBusyTest.java index 07a971987..e2a197675 100644 --- a/src/test/java/net/fortuna/ical4j/model/component/VFreeBusyTest.java +++ b/src/test/java/net/fortuna/ical4j/model/component/VFreeBusyTest.java @@ -397,7 +397,7 @@ public static TestSuite suite() throws ParseException, URISyntaxException { suite.addTest(new VFreeBusyTest("testPeriodCount", requestFree, components, 1)); // period should be from the start to the end date.. - PeriodList periods = new PeriodList<>(); + PeriodList periods = new PeriodList<>(CalendarDateFormat.UTC_DATE_TIME_FORMAT); periods.add(new Period<>(start, end)); suite.addTest(new VFreeBusyTest("testFreeBusyPeriods", requestFree, components, periods)); @@ -417,7 +417,7 @@ public static TestSuite suite() throws ParseException, URISyntaxException { // suite.addTest(new VFreeBusyTest("testFbType", request, components, FbType.BUSY)); suite.addTest(new VFreeBusyTest("testPeriodCount", request, components, 1)); - periods = new PeriodList<>(); + periods = new PeriodList<>(CalendarDateFormat.UTC_DATE_TIME_FORMAT); periods.add(new Period<>((Instant) TemporalAdapter.parse("20050104T080000Z").getTemporal(), java.time.Duration.parse("PT5H"))); suite.addTest(new VFreeBusyTest("testFreeBusyPeriods", request, components, periods)); @@ -444,7 +444,7 @@ public static TestSuite suite() throws ParseException, URISyntaxException { suite.addTest(new VFreeBusyTest("testFbType", request, components, FbType.FREE)); suite.addTest(new VFreeBusyTest("testPeriodCount", request, components, 1)); - periods = new PeriodList<>(); + periods = new PeriodList<>(CalendarDateFormat.UTC_DATE_TIME_FORMAT); periods.add(new Period<>(start, java.time.Duration.ofMinutes(30))); suite.addTest(new VFreeBusyTest("testFreeBusyPeriods", request, components, periods));