vanja
(galaxy)
January 8, 2026, 6:19am
1
Hi, after upgrading from 4.2 to 4.3.9 I got this:
The method getZonedDateTime() from the type DateTimeType is deprecated
I fixed it in some other rules where I just added ZoneId.systemDefault() as advised, but it doesn’t seem applicable for this specific rule:
Duration.between(now, (Sunrise_Time.state as DateTimeType).zonedDateTime).abs.toMinutes
I am calculating minutes between now and sunrise. I think this still works, can I ignore the warning for now, or?
vanja
(galaxy)
January 8, 2026, 7:00am
2
the notorious AI suggested
Duration.between(now, (Sunrise_Time.state as DateTimeType).getInstant.atZone(ZoneId.systemDefault())).abs.toMinutes
and it works. no more warnings, but still calculates correctly.
EDIT: of course, that was not his first attempt, first were some hallucinations.
rlkoshak
(Rich Koshak)
January 8, 2026, 3:44pm
3
I don’t know that the atZone is required. My understanding on how Duration works, it will convert the ZonedDateTime now to an Instant. But it’s been a long time since I’ve worked with Java ZonedDateTimes so I might be misremembering. But it’s an easy experiment to run.