mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-10 07:02:02 +01:00
Simplify DateTimeType handling for DBQuery
Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
This commit is contained in:
parent
bb9a789d31
commit
8d0653a161
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user