DateTime.postUpdate(DateTime t)

To make it short, I have a DateTime item and want to set it from inside a rule. This is working:

var DateTime deadline = now.plusSeconds(120)

toString() is needed as postUpdate only accepts Number, State, String.
Seems obvious that a DateTime Item should accept a DateTime variable!?

Am I missing something?

I think you need to use the DateTimeType in your rule.

I have a DateTime item and a rule that updates it:

postUpdate(Weather_LastUpdate, new DateTimeType())
1 Like

Yes, and you can create a DateTimeType set to the time in a DateTime object like this:

  postUpdate(Weather_LastUpdate, new DateTimeType(deadline.toCalendar(null)))
1 Like

Both make sense. Thanks guys! That’s what I was looking for.
As I see it DateTimeType is a data type defined in openhab in Don’t you think a publicly available javadoc (at gh-pages for example) would be wise and helpful for openhab apprentices? :wink:

1 Like

This is depricated.

How can i do this in openhab 2.3 snapshot?

I have a var DateTime and want to get an item DateTime out of it.

Only problem is to change the var to the item.

Also i want to do some math with it like this:

val mins = (now.millis - my_datetime_var.millis) / 60000

To get the time since the last timestamp in the variable.

This works.

I got it working: