From 308fdaaf544e05b6af99b504188d349f6298a295 Mon Sep 17 00:00:00 2001 From: Thomas Kurz Date: Thu, 30 Nov 2023 14:04:39 +0100 Subject: [PATCH] HOTFIX prevent NPE for relative dates and correct md for instant creation --- .../io/redlink/more/data/model/scheduler/RelativeDate.java | 3 +++ .../java/io/redlink/more/data/schedule/SchedulerUtils.java | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/java/io/redlink/more/data/model/scheduler/RelativeDate.java b/src/main/java/io/redlink/more/data/model/scheduler/RelativeDate.java index c2d2be7..a83a502 100644 --- a/src/main/java/io/redlink/more/data/model/scheduler/RelativeDate.java +++ b/src/main/java/io/redlink/more/data/model/scheduler/RelativeDate.java @@ -22,6 +22,9 @@ public int getMinutes() { } private int getTimeGroup(int i) { + if(time == null) { + return 0; + } Matcher m = CLOCK.matcher(time); if(m.find()) { return Integer.parseInt(m.group(i)); diff --git a/src/main/java/io/redlink/more/data/schedule/SchedulerUtils.java b/src/main/java/io/redlink/more/data/schedule/SchedulerUtils.java index 00e4870..b0ad64e 100644 --- a/src/main/java/io/redlink/more/data/schedule/SchedulerUtils.java +++ b/src/main/java/io/redlink/more/data/schedule/SchedulerUtils.java @@ -64,7 +64,10 @@ private static Instant shiftStartIfNecessary(Instant start) { private static Instant toInstant(RelativeDate date, Instant start) { return ZonedDateTime.ofInstant(start.plus(date.getOffset().getValue() - 1L, date.getOffset().getUnit().toTemporalUnit()), ZoneId.systemDefault()) .withHour(date.getHours()) - .withMinute(date.getMinutes()).toInstant(); + .withMinute(date.getMinutes()) + .withSecond(0) + .withNano(0) + .toInstant(); } public static List> parseToObservationSchedulesForEvent(Event event, Instant start, Instant end) {