# zonedDateTime deprecated question after upgrade

**URL:** <https://community.openhab.org/t/zoneddatetime-deprecated-question-after-upgrade/167893>\
**Category:** Migration\
**Tags:** rules-dsl\
**Created:** [January 8, 2026, 6:19am UTC](https://community.openhab.org/t/zoneddatetime-deprecated-question-after-upgrade/167893 "2026-01-08T06:19:24Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![vanja](https://community.openhab.org/letter_avatar_proxy/v4/letter/v/41988e/32.png) [@vanja](https://community.openhab.org/u/vanja)\
**Post date:** [January 8, 2026, 6:19am UTC](https://community.openhab.org/t/zoneddatetime-deprecated-question-after-upgrade/167893/1 "2026-01-08T06:19:24Z")

</div>

Hi, after upgrading from 4.2 to 4.3.9 I got this:

```auto
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:

```auto
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?

---

<div class="post-metadata">

**Author:** ![vanja](https://community.openhab.org/letter_avatar_proxy/v4/letter/v/41988e/32.png) [@vanja](https://community.openhab.org/u/vanja)\
**Post date:** [January 8, 2026, 7:00am UTC](https://community.openhab.org/t/zoneddatetime-deprecated-question-after-upgrade/167893/2 "2026-01-08T07:00:12Z")

</div>

the notorious AI suggested

```auto
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.

---

<div class="post-metadata">

**Author:** ![rlkoshak](https://community.openhab.org/user_avatar/community.openhab.org/rlkoshak/32/75251_2.png) [@rlkoshak](https://community.openhab.org/u/rlkoshak)\
**Post date:** [January 8, 2026, 3:44pm UTC](https://community.openhab.org/t/zoneddatetime-deprecated-question-after-upgrade/167893/3 "2026-01-08T15:44:42Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![laursen](https://community.openhab.org/letter_avatar_proxy/v4/letter/l/dfb087/32.png) [@laursen](https://community.openhab.org/u/laursen)\
**Post date:** [January 24, 2026, 12:04pm UTC](https://community.openhab.org/t/zoneddatetime-deprecated-question-after-upgrade/167893/4 "2026-01-24T12:04:49Z")

</div>

> [@vanja](#):
>
> and it works. no more warnings, but still calculates correctly.

For completeness, this would also work:

```java
Duration.between(Instant::now(), (Sunrise_Time.state as DateTimeType).instant).abs.toMinutes

```

In case your system time zone is different from the time zone configured in openHAB, this would still work correctly, while the AI-generated suggestion would not.
