DateTime item and UTC

I’m retrieving an UTC datetime string looking like this 2019-06-12T17:30:19Z.

This is retrieved with the HTTP binding like this:

metCache.url=https://api.met.no/weatherapi/nowcast/0.9/?lat=XX.XXXX&lon=YY.YYYY

Using the XPATH transformation like this:

DateTime metPrecipitationDateTimeCreated { http="<[metCache:10000:XPATH(//weatherdata[1]/@created)]" }

I’m at UTC+1 and are adjusting for daylight summertime, so for the moment I’m at UTC +2.

Openhab is aware of this, because when I output the datetime item as a string value on the sitemap as [%s] it writes 2019-06-12T17:30:19+2:00.

How can I show this string as the correct local time which is 19:30?

What Item type are you storing this value into?

Initial post is now updated with this information. I’m storing it into a DateTime item type.

As best as I can tell it is not parsing the string correctly. You should probably file an issue.

The only way to address this yourself is to use a proxy Item and a Rule to add the hours .

For me it seems like its parsing the string correctly, since sitemap in openhab outputs the value as 2019-06-12T17:30:19+2:00. It automatically appended +2:00 from the input datetime which is a UTC datetime (decided by the trailing Z). I don’t know how openhab deals with UTC and local time, and how to specify to format the datetime as local datetime instead of UTC…

But that isn’t correct. The correct output would be 2019-06-12T17:30:19Z or 2019-06-12T19:30:19+2:00 if it saw the string as UTC. With the +2:00 it is treating the UTC string as if it were in your time zone. That is incorrect. Put another way, it’s treating the UTC time as if it were in your time zone without adding the +2 hour offset.

Thanks, you are correct. I’ve filed an issue: https://github.com/openhab/openhab-core/issues/872