Rule DateTime conversion error after move from OH2.5 -> 3.1

I have DateTime items Smhi_Date_dn, but when using the following code in a rule

Smhi_Date_d3.postUpdate(now.plusDays(3).toString)

that worked fine in 2.5, I get the following error:

2021-08-23 09:00:00.108 [WARN ] [b.core.model.script.actions.BusEvent] - Cannot convert '2021-08-26T09:00:00.107674+02:00[Europe/Berlin]' to a state type which item 'Smhi_Date_d3' accepts: [DateTimeType, UnDefType].

Any ideas on what’s causing this?

Platform information: 2.5 was an OpenHABian installation while 3.1 is run in a Docker container on a NUC, Ubuntu 20.4.1 and Java: openjdk version “11.0.12” 2021-07-20 LTS
OpenJDK Runtime Environment Zulu11.50+19-CA (build 11.0.12+7-LTS)
OpenJDK 64-Bit Server VM Zulu11.50+19-CA (build 11.0.12+7-LTS, mixed mode)

Just use now.plusDays(3) without the toString or if that doesn’t work use new DateTimeType(now.plusDays(3)).

1 Like

Great, thanks - the second option using new worked just fine.