adapted DataTimeType mapping to new ESH type (#239)

Signed-off-by: Kai Kreuzer <kai@openhab.org>
This commit is contained in:
Kai Kreuzer 2017-12-01 18:05:38 +01:00 committed by GitHub
parent 3f1af862bc
commit 73688b7bd2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 2 deletions

View File

@ -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

View File

@ -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)) {