From 96b5ad2e55807c28a28fdb6ae8571e8be8232ece Mon Sep 17 00:00:00 2001 From: Jacob Laursen Date: Sat, 16 Nov 2024 00:46:58 +0100 Subject: [PATCH] Simplify DateTimeType handling for Shelly Signed-off-by: Jacob Laursen --- .../binding/shelly/internal/manager/ShellyManagerPage.java | 1 - .../openhab/binding/shelly/internal/util/ShellyUtils.java | 6 +----- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/manager/ShellyManagerPage.java b/bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/manager/ShellyManagerPage.java index fc35d708b1a..c24129a8d27 100644 --- a/bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/manager/ShellyManagerPage.java +++ b/bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/manager/ShellyManagerPage.java @@ -345,7 +345,6 @@ public class ShellyManagerPage { value = dateTimeState.format(null).replace('T', ' ').replace('-', '/'); break; default: - value = getTimestamp(dateTimeState); value = dateTimeState.format(null).replace('T', ' ').replace('-', '/'); } } else { diff --git a/bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/util/ShellyUtils.java b/bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/util/ShellyUtils.java index 735921565b4..91abc42b538 100644 --- a/bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/util/ShellyUtils.java +++ b/bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/util/ShellyUtils.java @@ -304,17 +304,13 @@ public class ShellyUtils { ZoneId zoneId = !zone.isEmpty() ? ZoneId.of(zone) : ZoneId.systemDefault(); ZonedDateTime zdt = LocalDateTime.now().atZone(zoneId); int delta = zdt.getOffset().getTotalSeconds(); - return new DateTimeType(ZonedDateTime.ofInstant(Instant.ofEpochSecond(timestamp - delta), zoneId)); + return new DateTimeType(Instant.ofEpochSecond(timestamp - delta)); } catch (DateTimeException e) { // Unable to convert device's timezone, use system one return getTimestamp(); } } - public static String getTimestamp(DateTimeType dt) { - return dt.getZonedDateTime().toString().replace('T', ' ').replace('-', '/'); - } - public static String convertTimestamp(long ts) { if (ts == 0) { return "";