From d871b66d3c7f06f391f4803c08b6c6a4a4d19e23 Mon Sep 17 00:00:00 2001 From: Jacob Laursen Date: Sat, 9 Nov 2024 22:33:00 +0100 Subject: [PATCH] Simplify DateTimeType handling for Network Signed-off-by: Jacob Laursen --- .../binding/network/internal/handler/NetworkHandler.java | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/bundles/org.openhab.binding.network/src/main/java/org/openhab/binding/network/internal/handler/NetworkHandler.java b/bundles/org.openhab.binding.network/src/main/java/org/openhab/binding/network/internal/handler/NetworkHandler.java index b6995792f88..3f460daa3f8 100644 --- a/bundles/org.openhab.binding.network/src/main/java/org/openhab/binding/network/internal/handler/NetworkHandler.java +++ b/bundles/org.openhab.binding.network/src/main/java/org/openhab/binding/network/internal/handler/NetworkHandler.java @@ -17,12 +17,10 @@ import static org.openhab.binding.network.internal.utils.NetworkUtils.durationTo import java.time.Duration; import java.time.Instant; -import java.time.ZonedDateTime; import java.util.Collection; import java.util.List; import java.util.Map; import java.util.Set; -import java.util.TimeZone; import org.eclipse.jdt.annotation.NonNullByDefault; import org.openhab.binding.network.internal.NetworkBindingConfiguration; @@ -104,8 +102,7 @@ public class NetworkHandler extends BaseThingHandler case CHANNEL_LASTSEEN: Instant lastSeen = presenceDetection.getLastSeen(); if (lastSeen != null) { - updateState(CHANNEL_LASTSEEN, new DateTimeType( - ZonedDateTime.ofInstant(lastSeen, TimeZone.getDefault().toZoneId()).withFixedOffsetZone())); + updateState(CHANNEL_LASTSEEN, new DateTimeType(lastSeen)); } else { updateState(CHANNEL_LASTSEEN, UnDefType.UNDEF); } @@ -146,8 +143,7 @@ public class NetworkHandler extends BaseThingHandler Instant lastSeen = presenceDetection.getLastSeen(); if (value.isReachable() && lastSeen != null) { - updateState(CHANNEL_LASTSEEN, new DateTimeType( - ZonedDateTime.ofInstant(lastSeen, TimeZone.getDefault().toZoneId()).withFixedOffsetZone())); + updateState(CHANNEL_LASTSEEN, new DateTimeType(lastSeen)); } else if (!value.isReachable() && lastSeen == null) { updateState(CHANNEL_LASTSEEN, UnDefType.UNDEF); }