[SOLVED] DateTimeType(Calendar) is deprecated - How to assign lastUpdate to an DateTime Item?

Seems to be a never ending story…

I once had a DateTime Item with a time stamp. To get this time stamp back when restarting openHAB, I decided not to store this time stamp separately but to get the time stamp from persistence service:


Well, this stopped working around 09-2015, I’m using openHAB quite a while… :wink:

The solution was this code snippet:

import java.util.Calendar
// ...
var Calendar cal = Calendar::getInstance()
MyItem_LastUpdate.postUpdate(new DateTimeType(cal))

And this code is reliable since then (orirginal posting here, thanks @watou)

But as DateTimeType(Calendar) now is deprecated, I’m a bit lost. I could not get things to work without DateTimeType. The code is still working, but openHAB complains about, so better change it now…

How about…


Ah! much less complex… :slight_smile: