Skip to content

Commit

Permalink
Convert parsed list to UTC format
Browse files Browse the repository at this point in the history
  • Loading branch information
benfortuna committed Jun 13, 2020
1 parent ee7cb8a commit 783b3f9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
11 changes: 9 additions & 2 deletions src/main/java/net/fortuna/ical4j/model/PeriodList.java
Expand Up @@ -95,8 +95,15 @@ public PeriodList(Collection<Period<T>> periods, CalendarDateFormat dateFormat)
* @throws java.time.format.DateTimeParseException thrown when an invalid string representation of a period list
* is provided
*/
public static PeriodList parse(final String aValue) {
return new PeriodList<>(Arrays.stream(aValue.split(",")).map(Period::parse).collect(Collectors.toList()));
public static <T extends Temporal> PeriodList<T> parse(final String aValue) {
return parse(aValue, CalendarDateFormat.FLOATING_DATE_TIME_FORMAT);
}

@SuppressWarnings("unchecked")
public static <T extends Temporal> PeriodList<T> parse(final String aValue, CalendarDateFormat calendarDateFormat) {
return (PeriodList<T>) new PeriodList<>(
Arrays.stream(aValue.split(",")).map(Period::parse).collect(Collectors.toList()),
calendarDateFormat);
}

@Override
Expand Down
Expand Up @@ -178,10 +178,8 @@ public final List<Period<Instant>> getPeriods() {
/**
* {@inheritDoc}
*/
@SuppressWarnings("unchecked")
public final void setValue(final String aValue) {
periods = new PeriodList<Instant>(PeriodList.parse(aValue).getPeriods(),
CalendarDateFormat.UTC_DATE_TIME_FORMAT);
periods = PeriodList.parse(aValue, CalendarDateFormat.UTC_DATE_TIME_FORMAT);
}

/**
Expand Down

0 comments on commit 783b3f9

Please sign in to comment.