Skip to content

Commit b2c9abb

Browse files
jlaurlsiepel
authored andcommitted
Simplify DateTimeType handling for Java Persistence API
Signed-off-by: Jacob Laursen <[email protected]>
1 parent e794c6a commit b2c9abb

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

bundles/org.openhab.persistence.jpa/src/main/java/org/openhab/persistence/jpa/internal/JpaHistoricItem.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,7 @@ public static List<HistoricItem> fromResultList(List<JpaPersistentItem> jpaQuery
142142
} else if (item instanceof RollershutterItem) {
143143
state = PercentType.valueOf(pItem.getValue());
144144
} else if (item instanceof DateTimeItem) {
145-
state = new DateTimeType(ZonedDateTime.ofInstant(Instant.ofEpochMilli(Long.parseLong(pItem.getValue())),
146-
ZoneId.systemDefault()));
145+
state = new DateTimeType(Instant.ofEpochMilli(Long.parseLong(pItem.getValue())));
147146
} else if (item instanceof LocationItem) {
148147
PointType pType = null;
149148
String[] comps = pItem.getValue().split(";");

bundles/org.openhab.persistence.jpa/src/main/java/org/openhab/persistence/jpa/internal/StateHelper.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public class StateHelper {
3737
*/
3838
public static String toString(State state) {
3939
if (state instanceof DateTimeType type) {
40-
return String.valueOf(type.getZonedDateTime().toInstant().toEpochMilli());
40+
return String.valueOf(type.getInstant().toEpochMilli());
4141
}
4242
if (state instanceof DecimalType type) {
4343
return String.valueOf(type.doubleValue());

0 commit comments

Comments
 (0)