Skip to content

Commit

Permalink
Fixed date formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
benfortuna committed Jul 4, 2020
1 parent dbc3d9e commit f16f5d7
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 13 deletions.
5 changes: 1 addition & 4 deletions src/main/java/net/fortuna/ical4j/model/Period.java
Expand Up @@ -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]
*
Expand Down Expand Up @@ -363,7 +360,7 @@ public final PeriodList<T> subtract(final Period<T> 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));
}
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/net/fortuna/ical4j/model/PeriodList.java
Expand Up @@ -151,7 +151,7 @@ public final boolean remove(final Object period) {
public final PeriodList<T> normalise() {
Period<T> prevPeriod = null;
Period<T> period;
final PeriodList<T> newList = new PeriodList<>();
final PeriodList<T> newList = new PeriodList<>(dateFormat);
boolean normalised = false;
for (Period<T> period1 : periods) {
period = period1;
Expand Down Expand Up @@ -208,7 +208,7 @@ public final PeriodList<T> normalise() {
*/
public final PeriodList<T> add(final PeriodList<T> periods) {
if (periods != null) {
final PeriodList<T> newList = new PeriodList<>();
final PeriodList<T> newList = new PeriodList<>(dateFormat);
newList.getPeriods().addAll(this.periods);
newList.getPeriods().addAll(this.periods);
return newList.normalise();
Expand All @@ -231,7 +231,7 @@ public final PeriodList<T> subtract(final PeriodList<T> subtractions) {
}

PeriodList<T> result = this;
PeriodList<T> tmpResult = new PeriodList<>();
PeriodList<T> tmpResult = new PeriodList<>(dateFormat);

for (final Period<T> subtraction : subtractions.getPeriods()) {
for (final Period<T> period : result.getPeriods()) {
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/net/fortuna/ical4j/model/property/FreeBusy.java
Expand Up @@ -115,7 +115,7 @@ public class FreeBusy extends Property {
*/
public FreeBusy() {
super(FREEBUSY);
periods = new PeriodList<>();
periods = new PeriodList<>(CalendarDateFormat.UTC_DATE_TIME_FORMAT);
}

/**
Expand All @@ -140,7 +140,7 @@ public FreeBusy(final ParameterList aList, final String aValue) {
*/
public FreeBusy(final List<Period<Instant>> pList) {
super(FREEBUSY);
periods = new PeriodList<>(pList);
periods = new PeriodList<>(pList, CalendarDateFormat.UTC_DATE_TIME_FORMAT);
}

/**
Expand All @@ -149,7 +149,7 @@ public FreeBusy(final List<Period<Instant>> pList) {
*/
public FreeBusy(final ParameterList aList, final List<Period<Instant>> pList) {
super(FREEBUSY, aList);
periods = new PeriodList<>(pList);
periods = new PeriodList<>(pList, CalendarDateFormat.UTC_DATE_TIME_FORMAT);
}

/**
Expand Down
Expand Up @@ -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<Instant> periods = new PeriodList<>();
PeriodList<Instant> periods = new PeriodList<>(CalendarDateFormat.UTC_DATE_TIME_FORMAT);
periods.add(new Period<>(start, end));
suite.addTest(new VFreeBusyTest("testFreeBusyPeriods", requestFree, components, periods));

Expand All @@ -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));
Expand All @@ -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));

Expand Down

0 comments on commit f16f5d7

Please sign in to comment.