Migration issues OH2 to OH3

Good day openHABians,

its my first post here, so first i want to thank you for your good work regarding the software we all love :slight_smile:
I am in the middle of a migration from OH 2.5.6 to OH 3.0.0 and i am struggeling with some rule issues.

I have a rule for posting the last update of an item.
In OH 2.5.6 this was no problem:
postUpdate(triggeringItem.name + “_LastUpdate”, now.toString(“dd.MM.yyyy - HH:mm”))
I received like this: "05.01.2021 - 08:00"

In OH 3.0.0 i have problems to get this done.
I am now receiving: "2021-01-05T11:45:39.804721+01:00[Europe/Berlin]"

Can i receive the old format in a simple single line with OH3 again?

With this i can receive “nearly” the same result as before:
postUpdate(triggeringItem.name + “_LastUpdate”, now.toLocalDateTime().toString())

I tried several things from other posts (like DateTime Conversion (openHAB 3.x), …) but with no luck.

Thanks in advance :smiley:

OH 3 now uses ZonedDateTime for now instead of Joda DateTime and there are differences. I don’t see a toString that takes a format like that but to avoid the XY Problem, why are you doing it this way? Why isn’t the LastUpdate Items a DateTime in which case you can use postUpdate(triggeringItem.name + "_LastUpdate", new DateTimeType().toString()) and then you can use the standard formatting stuff in the Item label/State formatting: Items | openHAB.

Even in OH 2.5 this would be a the better approach. You can actually do stuff with a DateTime Item so why not let it stay one and just change how it gets shown to you the human?

A further question is what is triggeringItem and is it linked to a Channel? If so, you don’t even need this in a rule. You can use the Timestamp Profile on the Link and when ever the Item changes or is updated the LastUpdate Items will be set with the current timestamp. And you can then again use the standard formatting on the label to make it appear as you perfer.

1 Like

Hi Rich,
many thanks for your solution.
Unfortunately my kids keeping me very busy these days, so i will try this solution on weekend.
But i am sure this will do the trick :slight_smile:

Big thanks again and stay healthy !