Skip to content

Commit

Permalink
Better fix of dataformat
Browse files Browse the repository at this point in the history
  • Loading branch information
JiriOndrusek committed Jun 21, 2024
1 parent 2633151 commit 2432393
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,10 @@
package org.apache.camel.quarkus.component.dataformat.it;

import java.net.URI;
import java.time.DateTimeException;
import java.time.Instant;
import java.time.ZonedDateTime;

import net.fortuna.ical4j.model.Calendar;
import net.fortuna.ical4j.model.DateTime;
import net.fortuna.ical4j.model.TimeZoneRegistry;
import net.fortuna.ical4j.model.TimeZoneRegistryFactory;
import net.fortuna.ical4j.model.component.VEvent;
Expand All @@ -49,8 +47,8 @@ protected static Calendar createTestCalendar(ZonedDateTime start, ZonedDateTime
// Create the event
VEvent meeting = new VEvent();
meeting.replace(new DtStamp(Instant.ofEpochMilli(0)));
meeting.add(new DtStart(toDateTime(start, registry).toInstant()));
meeting.add(new DtEnd(toDateTime(end, registry).toInstant()));
meeting.add(new DtStart(start));
meeting.add(new DtEnd(end));
meeting.add(new Summary(summary));

// add timezone info..
Expand All @@ -76,8 +74,4 @@ protected static Calendar createTestCalendar(ZonedDateTime start, ZonedDateTime
return icsCalendar;
}

static DateTime toDateTime(ZonedDateTime zonedDateTime, TimeZoneRegistry registry) {
return new DateTime(zonedDateTime.toInstant().toEpochMilli());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ public void ical() throws ParseException, IOException {
final String icsTemplate = IOUtils.toString(getClass().getResourceAsStream("/test.ics"), StandardCharsets.UTF_8);
final String icalString = String.format(
icsTemplate,
ZoneId.systemDefault().getId(),
toFormatedLocalDateTime(START),
ZoneId.systemDefault().getId(),
toFormatedLocalDateTime(END),
START.getZone().getId());

Expand Down
4 changes: 2 additions & 2 deletions integration-tests/dataformat/src/test/resources/test.ics
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ PRODID:-//Events Calendar//iCal4j 1.0//EN
CALSCALE:GREGORIAN
BEGIN:VEVENT
DTSTAMP:19700101T000000Z
DTSTART:%s
DTEND:%s
DTSTART;TZID=%s:%s
DTEND;TZID=%s:%s
SUMMARY:Progress Meeting
TZID:%s
UID:00000000
Expand Down

0 comments on commit 2432393

Please sign in to comment.