From 73688b7bd2e9f5b5c18a7858ebd0cf3a6521c421 Mon Sep 17 00:00:00 2001 From: Kai Kreuzer Date: Fri, 1 Dec 2017 18:05:38 +0100 Subject: [PATCH] adapted DataTimeType mapping to new ESH type (#239) Signed-off-by: Kai Kreuzer --- .../org/openhab/core/compat1x/internal/TypeMapperTest.java | 2 +- .../java/org/openhab/core/compat1x/internal/TypeMapper.java | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/bundles/org.openhab.core.compat1x.test/src/test/java/org/openhab/core/compat1x/internal/TypeMapperTest.java b/bundles/org.openhab.core.compat1x.test/src/test/java/org/openhab/core/compat1x/internal/TypeMapperTest.java index 76d105cff..c5e2ebde9 100644 --- a/bundles/org.openhab.core.compat1x.test/src/test/java/org/openhab/core/compat1x/internal/TypeMapperTest.java +++ b/bundles/org.openhab.core.compat1x.test/src/test/java/org/openhab/core/compat1x/internal/TypeMapperTest.java @@ -20,7 +20,7 @@ public class TypeMapperTest { public void testDateTypeType() { DateTimeType ohType1 = new DateTimeType(); DateTimeType ohType2 = (DateTimeType) TypeMapper.mapToOpenHABType(TypeMapper.mapToESHType(ohType1)); - assertEquals(ohType1, ohType2); + assertEquals(ohType1.toString(), ohType2.toString()); } @Test diff --git a/bundles/org.openhab.core.compat1x/src/main/java/org/openhab/core/compat1x/internal/TypeMapper.java b/bundles/org.openhab.core.compat1x/src/main/java/org/openhab/core/compat1x/internal/TypeMapper.java index f19a67770..8a7d5e3e8 100644 --- a/bundles/org.openhab.core.compat1x/src/main/java/org/openhab/core/compat1x/internal/TypeMapper.java +++ b/bundles/org.openhab.core.compat1x/src/main/java/org/openhab/core/compat1x/internal/TypeMapper.java @@ -10,6 +10,7 @@ package org.openhab.core.compat1x.internal; import java.lang.reflect.Field; import java.util.Calendar; +import java.util.GregorianCalendar; import org.eclipse.smarthome.core.library.types.DateTimeType; import org.eclipse.smarthome.core.library.types.DecimalType; @@ -73,7 +74,8 @@ public class TypeMapper { } else if (typeClass.equals(PercentType.class)) { result = new org.openhab.core.library.types.PercentType(type.toString()); } else if (typeClass.equals(DateTimeType.class)) { - result = new org.openhab.core.library.types.DateTimeType(cloneCalendar(type)); + result = new org.openhab.core.library.types.DateTimeType( + GregorianCalendar.from(((DateTimeType) type).getZonedDateTime())); } else if (typeClass.equals(PointType.class)) { result = new org.openhab.core.library.types.PointType(type.toString()); } else if (typeClass.equals(StringListType.class)) {