}
value = String.valueOf(decimalValue);
break;
case 19:
DPTXlatorDateTime translatorDateTime = (DPTXlatorDateTime) translator;
if (translatorDateTime.isFaultyClock()) {
//Not supported: faulty clock
logger.debug("toType: KNX clock msg ignored: clock faulty bit set, which is not supported");
return null;
}
else if (!translatorDateTime.isValidField(DPTXlatorDateTime.YEAR) && translatorDateTime.isValidField(DPTXlatorDateTime.DATE)){
//Not supported: "/1/1" (month and day without year)
logger.debug("toType: KNX clock msg ignored: no year, but day and month, which is not supported");
return null;
}
else if (translatorDateTime.isValidField(DPTXlatorDateTime.YEAR) && !translatorDateTime.isValidField(DPTXlatorDateTime.DATE)){
//Not supported: "1900" (year without month and day)
logger.debug("toType: KNX clock msg ignored: no day and month, but year, which is not supported");
return null;
}
else if (!translatorDateTime.isValidField(DPTXlatorDateTime.YEAR)
&& !translatorDateTime.isValidField(DPTXlatorDateTime.DATE)
&& !translatorDateTime.isValidField(DPTXlatorDateTime.TIME)) {
// Not supported: No year, no date and no time
logger.debug("toType: KNX clock msg ignored: no day and month or year, which is not supported");
return null;
}
Calendar cal = Calendar.getInstance();
if (translatorDateTime.isValidField(DPTXlatorDateTime.YEAR) && !translatorDateTime.isValidField(DPTXlatorDateTime.TIME)) {
// Pure date format, no time information
cal.setTimeInMillis(translatorDateTime.getValueMilliseconds());
value=DateTimeType.DATE_FORMATTER.format(cal.getTime());
return DateTimeType.valueOf(value);
}
else if (!translatorDateTime.isValidField(DPTXlatorDateTime.YEAR) && translatorDateTime.isValidField(DPTXlatorDateTime.TIME)) {
// Pure time format, no date information
cal.clear();
cal.set(Calendar.HOUR_OF_DAY, translatorDateTime.getHour());
cal.set(Calendar.MINUTE, translatorDateTime.getHour());
cal.set(Calendar.SECOND, translatorDateTime.getSecond());
value=DateTimeType.DATE_FORMATTER.format(cal.getTime());
return DateTimeType.valueOf(value);
}
else if (translatorDateTime.isValidField(DPTXlatorDateTime.YEAR) && translatorDateTime.isValidField(DPTXlatorDateTime.TIME)) {
// Date format and time information
cal.setTimeInMillis(translatorDateTime.getValueMilliseconds());
value=DateTimeType.DATE_FORMATTER.format(cal.getTime());
return DateTimeType.valueOf(value);
}
break;
}