From 164e333a40afe8840c14147e7f1dd63752107a54 Mon Sep 17 00:00:00 2001 From: Jacob Laursen Date: Tue, 19 Nov 2024 21:01:03 +0100 Subject: [PATCH] Simplify DateTimeType handling for Mercedes Me Signed-off-by: Jacob Laursen --- .../binding/mercedesme/internal/handler/VehicleHandler.java | 3 ++- .../org/openhab/binding/mercedesme/internal/utils/Utils.java | 3 +-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/bundles/org.openhab.binding.mercedesme/src/main/java/org/openhab/binding/mercedesme/internal/handler/VehicleHandler.java b/bundles/org.openhab.binding.mercedesme/src/main/java/org/openhab/binding/mercedesme/internal/handler/VehicleHandler.java index 50879587880..313afc3de13 100644 --- a/bundles/org.openhab.binding.mercedesme/src/main/java/org/openhab/binding/mercedesme/internal/handler/VehicleHandler.java +++ b/bundles/org.openhab.binding.mercedesme/src/main/java/org/openhab/binding/mercedesme/internal/handler/VehicleHandler.java @@ -14,6 +14,7 @@ package org.openhab.binding.mercedesme.internal.handler; import static org.openhab.binding.mercedesme.internal.Constants.*; +import java.time.ZoneId; import java.time.ZonedDateTime; import java.util.ArrayList; import java.util.Arrays; @@ -954,7 +955,7 @@ public class VehicleHandler extends BaseThingHandler { if (vas != null && !Utils.isNil(vas)) { // proto weekday starts with MONDAY=0, java ZonedDateTime starts with MONDAY=1 long estimatedWeekday = Utils.getInt(vas) + 1; - ZonedDateTime storedZdt = endDateTimeType.getZonedDateTime(); + ZonedDateTime storedZdt = endDateTimeType.getZonedDateTime(ZoneId.systemDefault()); long storedWeekday = storedZdt.getDayOfWeek().getValue(); // check if estimated weekday is smaller than stored // estimation Monday=1 vs. stored Saturday=6 => (7+1)-6=2 days ahead diff --git a/bundles/org.openhab.binding.mercedesme/src/main/java/org/openhab/binding/mercedesme/internal/utils/Utils.java b/bundles/org.openhab.binding.mercedesme/src/main/java/org/openhab/binding/mercedesme/internal/utils/Utils.java index 3be8fecdd3a..8d238afa7f5 100644 --- a/bundles/org.openhab.binding.mercedesme/src/main/java/org/openhab/binding/mercedesme/internal/utils/Utils.java +++ b/bundles/org.openhab.binding.mercedesme/src/main/java/org/openhab/binding/mercedesme/internal/utils/Utils.java @@ -107,8 +107,7 @@ public class Utils { * @return openHAB DateTimeType according to configured TimeZone */ public static DateTimeType getDateTimeType(long ms) { - Instant timestamp = Instant.ofEpochMilli(ms); - return new DateTimeType(timestamp.atZone(timeZoneProvider.getTimeZone())); + return new DateTimeType(Instant.ofEpochMilli(ms)); } /**