mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-10 15:11:59 +01:00
Simplify DateTimeType handling for Java Persistence API
Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
This commit is contained in:
parent
e794c6a0f6
commit
b2c9abbe29
@ -142,8 +142,7 @@ public class JpaHistoricItem implements HistoricItem {
|
|||||||
} else if (item instanceof RollershutterItem) {
|
} else if (item instanceof RollershutterItem) {
|
||||||
state = PercentType.valueOf(pItem.getValue());
|
state = PercentType.valueOf(pItem.getValue());
|
||||||
} else if (item instanceof DateTimeItem) {
|
} else if (item instanceof DateTimeItem) {
|
||||||
state = new DateTimeType(ZonedDateTime.ofInstant(Instant.ofEpochMilli(Long.parseLong(pItem.getValue())),
|
state = new DateTimeType(Instant.ofEpochMilli(Long.parseLong(pItem.getValue())));
|
||||||
ZoneId.systemDefault()));
|
|
||||||
} else if (item instanceof LocationItem) {
|
} else if (item instanceof LocationItem) {
|
||||||
PointType pType = null;
|
PointType pType = null;
|
||||||
String[] comps = pItem.getValue().split(";");
|
String[] comps = pItem.getValue().split(";");
|
||||||
|
@ -37,7 +37,7 @@ public class StateHelper {
|
|||||||
*/
|
*/
|
||||||
public static String toString(State state) {
|
public static String toString(State state) {
|
||||||
if (state instanceof DateTimeType type) {
|
if (state instanceof DateTimeType type) {
|
||||||
return String.valueOf(type.getZonedDateTime().toInstant().toEpochMilli());
|
return String.valueOf(type.getInstant().toEpochMilli());
|
||||||
}
|
}
|
||||||
if (state instanceof DecimalType type) {
|
if (state instanceof DecimalType type) {
|
||||||
return String.valueOf(type.doubleValue());
|
return String.valueOf(type.doubleValue());
|
||||||
|
Loading…
Reference in New Issue
Block a user