Extending a timer based on itself

I have a timer which I want to reschedule. All the examples I can find are based on [now] + [some time]. I would like to reschedule my timer based on [time of timer] + [some time].

Ideally what I would like is something like this:

var LocalDateTime time = null
var Timer timer = null

rule "Example rule"
when
    Item Sensor_State changed to ON
then
    if (timer === null || timer.hasTerminated) {
        time = now.plusSeconds(30);
         timer = createTimer(time, [| 
            // Do something
        ]);
    } else {
        time = time.plusSeconds(10);
        timer.reschedule(time);
    }
end

Problem is that it’s not possible to invoke plusSeconds on the LocalDateTime object. I’ve tried using different objects but I get the same problem if I use DateTimeType or Instant.

Is this possible? And if so what am I doing wrong here?

In OH3, createTimer() wants a ZonedDateTime object as parameter.

In OH3 DSL, now is a ZonedDateTime object.

Thanks that seems to have done the trick. Curious though where you found out about it wanting a ZonedDateTime object. On the documentation page (Actions | openHAB) it only says it wants an AbstractInstant. And I can create timers fine with a LocalDateTime object.

Also why does plusSeconds work on ZonedDateTime objects but not LocalDateTime objects?

Is there a more technical manual for how these things work in OpenHAB? Or a way to find out yourself?

Mostly based on “what works”.
VSCode with openHAB extension offers helpful options to experimenters.

now and createTimer() are openHAB constructs, but

that’s Java business