Parse a date string in OH 3.2.0 fails

In OH 3.0 and 3.1 I successfully used the following commands in DSL rules to query values from InfluxDB:

.sumSince(parse(“2019-03-28” + “T00:00:00+01:00”))
.deltaSince(parse(now.getYear() + “-01-01” + “T00:00:00+01:00”))

In OH 3.2.0 it now returns the following failure:

Text cannot be parsed to a Duration

Can anyone tell me what has changed here and how I can adapt it?

Full example:

rule "PV: Ertrag dieses Jahr" 
    when
        Item PV_Gesamt_Ertrag changed
    then
        // PV_Gesamt_Ertrag.historicState(parse(now.getYear() + "-01-01" + "T00:00:00+01:00")).state)
        PV_DiesesJahr_Ertrag.postUpdate(PV_Gesamt_Ertrag.deltaSince(parse(now.getYear() + "-01-01" + "T00:00:00+01:00")))
end
2021-12-21 11:50:56.833 [ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID 'Photovoltaik-18' failed: Text cannot be parsed to a Duration in Photovoltaik

I found the solution. ZonedDateTime needs to be added before parse.

e.g.
.sumSince(ZonedDateTime.parse(“2019-03-28” + “T00:00:00+01:00”))

2 Likes

Thank You !!!