Simplify DateTimeType handling for DBQuery

Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
This commit is contained in:
Jacob Laursen 2024-12-09 23:33:01 +01:00 committed by lsiepel
parent bb9a789d31
commit 8d0653a161

View File

@ -16,8 +16,6 @@ import java.math.BigDecimal;
import java.math.BigInteger;
import java.time.Duration;
import java.time.Instant;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.util.Base64;
import java.util.Date;
@ -76,9 +74,9 @@ public class Value2StateConverter {
private State convert2DateTime(Object value) {
if (value instanceof Instant instant) {
return new DateTimeType(ZonedDateTime.ofInstant(instant, ZoneId.systemDefault()));
return new DateTimeType(instant);
} else if (value instanceof Date date) {
return new DateTimeType(ZonedDateTime.ofInstant(date.toInstant(), ZoneId.systemDefault()));
return new DateTimeType(date.toInstant());
} else if (value instanceof String string) {
return new DateTimeType(string);
} else {