diff --git a/bundles/org.openhab.persistence.jdbc/src/main/java/org/openhab/persistence/jdbc/internal/db/JdbcBaseDAO.java b/bundles/org.openhab.persistence.jdbc/src/main/java/org/openhab/persistence/jdbc/internal/db/JdbcBaseDAO.java index 177fbc291d7..20f945e32c2 100644 --- a/bundles/org.openhab.persistence.jdbc/src/main/java/org/openhab/persistence/jdbc/internal/db/JdbcBaseDAO.java +++ b/bundles/org.openhab.persistence.jdbc/src/main/java/org/openhab/persistence/jdbc/internal/db/JdbcBaseDAO.java @@ -639,8 +639,7 @@ public class JdbcBaseDAO { break; case "DATETIMEITEM": vo.setValueTypes(getSqlTypes().get(itemType), java.sql.Timestamp.class); - java.sql.Timestamp d = new java.sql.Timestamp( - ((DateTimeType) itemState).getZonedDateTime().toInstant().toEpochMilli()); + java.sql.Timestamp d = new java.sql.Timestamp(((DateTimeType) itemState).getInstant().toEpochMilli()); logger.debug("JDBC::storeItemValueProvider: DateTimeItem: '{}'", d); vo.setValue(d); break; @@ -684,7 +683,7 @@ public class JdbcBaseDAO { } return unit == null ? DecimalType.valueOf(objectAsString(v)) : QuantityType.valueOf(objectAsString(v)); } else if (item instanceof DateTimeItem) { - return new DateTimeType(objectAsInstant(v).atZone(ZoneId.systemDefault())); + return new DateTimeType(objectAsInstant(v)); } else if (item instanceof ColorItem) { return HSBType.valueOf(objectAsString(v)); } else if (item instanceof DimmerItem || item instanceof RollershutterItem) { diff --git a/bundles/org.openhab.persistence.jdbc/src/test/java/org/openhab/persistence/jdbc/internal/db/JdbcBaseDAOTest.java b/bundles/org.openhab.persistence.jdbc/src/test/java/org/openhab/persistence/jdbc/internal/db/JdbcBaseDAOTest.java index c72d9327366..69e8c9bc413 100644 --- a/bundles/org.openhab.persistence.jdbc/src/test/java/org/openhab/persistence/jdbc/internal/db/JdbcBaseDAOTest.java +++ b/bundles/org.openhab.persistence.jdbc/src/test/java/org/openhab/persistence/jdbc/internal/db/JdbcBaseDAOTest.java @@ -127,13 +127,11 @@ public class JdbcBaseDAOTest { LocalDateTime.parse("2021-02-01T23:30:02.049"), null, DateTimeType.valueOf("2021-02-01T23:30:02.049")), Arguments.of(new DateTimeItem("Long_DateTimeItem"), Long.valueOf("1612222202049"), null, - new DateTimeType(ZonedDateTime.ofInstant(Instant.parse("2021-02-01T23:30:02.049Z"), - ZoneId.systemDefault()))), + new DateTimeType(Instant.parse("2021-02-01T23:30:02.049Z"))), Arguments.of(new DateTimeItem("Date_DateTimeItem"), java.sql.Date.valueOf("2021-02-01"), null, DateTimeType.valueOf("2021-02-01T00:00:00.000")), Arguments.of(new DateTimeItem("Instant_DateTimeItem"), Instant.parse("2021-02-01T23:30:02.049Z"), null, - new DateTimeType(ZonedDateTime.ofInstant(Instant.parse("2021-02-01T23:30:02.049Z"), - ZoneId.systemDefault()))), + new DateTimeType(Instant.parse("2021-02-01T23:30:02.049Z"))), Arguments.of(new DateTimeItem("String_DateTimeItem"), "2021-02-01 23:30:02.049", null, DateTimeType.valueOf("2021-02-01T23:30:02.049"))); }