Open slawekjaranowski opened 6 years ago
There's a chance this is a bug in Java itself. Long story...
After some rather painful debugging, I find that the testToType()
method is returning null here because knxCoreTypeMapper.toType()
is returning null here.
Backtracing those leads to this call to translatorDateTime.getValueMilliseconds()
, which is throwing a KNXFormatException
:
tuwien.auto.calimero.exception.KNXFormatException: invalid calendar value: MINUTE: 2 -> 26
at tuwien.auto.calimero.dptxlator.DPTXlatorDateTime.fromDPTMilliseconds(DPTXlatorDateTime.java:738)
at tuwien.auto.calimero.dptxlator.DPTXlatorDateTime.getValueMilliseconds(DPTXlatorDateTime.java:446)
at org.openhab.binding.knx.internal.dpt.KNXCoreTypeMapper.toType(KNXCoreTypeMapper.java:477)
I wrote a simple little Java program to test the date conversion that the binding is wanting to do:
Calendar cal = Calendar.getInstance();
cal.set(1900, 0, 1, 1, 2, 3);
String formatted = String.format(Locale.US, "%1$ta, %1$tT", cal);
System.out.println("Formatted: " + formatted);
In the default timezone here, this results in the output Formatted: Mon, 01:02:03
.
In the Europe/Warsaw timezone, this results in the output Formatted: Mon, 01:26:03
.
There's a chance we're doing something wrong in setting up the calendar object, but I haven't been able to spot anything so far.
After a bit more review, I now believe this is a bug in the binding after all.
There are a number of places where the code assumes the system's locale is Locale.US
, when presumably it should be using the system's default locale instead.
Expected Behavior
Pass tests during build on system with default Europe/Warsaw timezone.
Current Behavior
Possible Solution
On system with default Europe/Warsaw timezone we can run:
mvn clean install -Dtycho.testArgLine="-Duser.timezone=UTC"
Steps to Reproduce (for bugs)
Build project on system with default Europe/Warsaw timezone or run:
mvn clean install -Dtycho.testArgLine="-Duser.timezone=Europe/Warsaw"