Hello,
I work on a smart meter simulator and I have trouble with the DLMS representation of GXDateTime when daylight saving is active. When I initialzie GXDateTime with the date 2017/03/26 03:00:00 CEST, the binary representation is the following
09 0C 07 E1 03 1A 07 01 00 00 00 00 78 80
It is wrong, because the time set to GXDateTime was 03:00, but the binary form contains 01. The sources of gurux.dlms.internal.GXCommon show that 1 hour is always deducted when daylight saving is active.
// If summer time.
if (summertime
|| dt.getStatus().contains(ClockStatus.DAYLIGHT_SAVE_ACTIVE)) {
tm.add(Calendar.HOUR, -1);
}
What is the correct way to initialize the GXDateTime object to get the correct number of hours in the byte form? I use the Europe/Bratislava timezone. Thank you.
We experience this problem using the following scenario:
The local time is set to 2017/03/26 CEST. We work with local time only.
Next we initialize an OffsetTime object to 03:00:00+02:00
Then an OffsetDateTime is created with the following code
The value of offsetDateTime is 2017-03-26 03:00:00+02:00 - so far so good.
Next we create the GXDateTime the following way
GXDateTime gxDateTime = new GXDateTime(Date.from(offsetDateTime.toInstant()));
This instance is then added to an object array and the object array added as a buffer to GXDLMSProfileGeneric.
The conversion to DLMS bytes is executed on profile read request. The GXDateTime is still fine and GXDateTime.toMeterTime().toString() returns the correct value Sun Mar 26 03:00:00 CEST 2017.
But the byte representation just does not seem right. I would like to ask for a little help how to get the right value to the hour field in the binary form. Thank You.
GXDateTime to DLMS bytes in daylight saving time
Hi,
First I want to make sure that are you using UTC or your local calendar? How you initialize GXDateTime?
BR,
Mikko
Hi Mikko,
Hi Mikko,
We experience this problem using the following scenario:
The local time is set to 2017/03/26 CEST. We work with local time only.
Next we initialize an OffsetTime object to 03:00:00+02:00
Then an OffsetDateTime is created with the following code
OffsetDateTime offsetDateTime = offsetTime.atDate(LocalDate.now());
The value of offsetDateTime is 2017-03-26 03:00:00+02:00 - so far so good.
Next we create the GXDateTime the following way
GXDateTime gxDateTime = new GXDateTime(Date.from(offsetDateTime.toInstant()));
This instance is then added to an object array and the object array added as a buffer to GXDLMSProfileGeneric.
The conversion to DLMS bytes is executed on profile read request. The GXDateTime is still fine and GXDateTime.toMeterTime().toString() returns the correct value Sun Mar 26 03:00:00 CEST 2017.
But the byte representation just does not seem right. I would like to ask for a little help how to get the right value to the hour field in the binary form. Thank You.
Best wishes,
Jozef
GXDateTime to DLMS bytes in daylight saving time
Hi,
We released new version today. 2.0.1. This is fixed.
BR,
Mikko