Skip to content

Commit c64ed13

Browse files
authored
Remove references to deprecated DateTimeType method getZonedDateTime (openhab#2432)
Signed-off-by: Jacob Laursen <[email protected]>
1 parent 85f084b commit c64ed13

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

configuration/actions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ Action | Returns
263263
`getNextBankHoliday` | name of the next bank holiday
264264
`getNextBankHoliday(<file>)` | name of the next bank holiday defined in `<file>`
265265
`getNextBankHoliday(<offset>)` | name of the next bank holiday after `<offset>` days from today
266-
`getNextBankHoliday(<offset>, <file>)` | name of the next bank holiday after `<offset>` days from today defined in `<file>`. :warning: This action is broken in OH 2.5.x. Use `getNextBankHoliday(<datetime>, <file>)` instead by replacing `<datetime>` with `new DateTimeType().zonedDateTime.now().plusDays(<offset>)`
266+
`getNextBankHoliday(<offset>, <file>)` | name of the next bank holiday after `<offset>` days from today defined in `<file>`. :warning: This action is broken in OH 2.5.x. Use `getNextBankHoliday(<datetime>, <file>)` instead by replacing `<datetime>` with `now.plusDays(<offset>)`
267267
`getNextBankHoliday(<datetime>)` | name of the next bank holiday after the day defined by the `ZonedDateTime` `<datetime>`
268268
`getNextBankHoliday(<datetime>, <file>)` | name of the next bank holiday after the day defined by the `ZonedDateTime` `<datetime>` defined in `<file>`
269269
`isBankHoliday` | `true` if today is a bank holiday (see below), `false` otherwise

configuration/rules-dsl.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -496,13 +496,13 @@ A DateTime Item carries a **DateTimeType**, which internally holds a Java `Zoned
496496

497497
```java
498498
// Get epoch from DateTimeType
499-
val Number epoch = (MyDateTimeItem.state as DateTimeType).zonedDateTime.toInstant.toEpochMilli
499+
val Number epoch = (MyDateTimeItem.state as DateTimeType).instant.toEpochMilli
500500

501501
// Get epoch from Java ZonedDateTime
502502
val Number nowEpoch = now.toInstant.toEpochMilli
503503

504504
// Convert DateTimeType to Java ZonedDateTime
505-
val javaZonedDateTime = (MyDateTimeItem.state as DateTimeType).zonedDateTime
505+
val javaZonedDateTime = (MyDateTimeItem.state as DateTimeType).getZonedDateTime(ZoneId.systemDefault)
506506

507507
// Convert Java ZonedDateTime to DateTimeType
508508
val DateTimeType date = new DateTimeType(now)
@@ -531,13 +531,13 @@ ZonedDateTimes provide a number of useful methods for comparing date times toget
531531

532532
```java
533533
// See if DateTimeType is before now
534-
if(now.isBefore((MyDateTimeItem.state as DateTimeType).zonedDateTime)) ...
534+
if(now.toInstant.isBefore((MyDateTimeItem.state as DateTimeType).instant)) ...
535535

536536
// See if DateTimeType is after now
537-
if(now.isAfter((MyDateTimeItem.state as DateTimeType).zonedDateTime)) ...
537+
if(now.toInstant.isAfter((MyDateTimeItem.state as DateTimeType).instant)) ...
538538

539539
// Get the hour in the day from a DateTimeType
540-
val hour = (MyDateTimeItem.state as DateTimeType).zonedDateTime.hour
540+
val hour = (MyDateTimeItem.state as DateTimeType).getZonedDateTime(ZoneId.systemDefault).hour
541541
```
542542

543543
##### Dimmer Item

0 commit comments

Comments
 (0)