I have the same problem of depreciated, and tried the toEpochSecond suggestion above, which errored and didn’t work.(I’m using OH 2.2 release version).
The depreciated line is the first one, and the second (commented out) is what i tried but was wrong. Can anyone please tell me what I need to use instead? Thanks.
var DateTime LastTagged = new DateTime((iTagDateTime.state as DateTimeType).calendar.timeInMillis)
// var DateTime LastTagged = new DateTime((iTagDateTime.state as DateTimeType).toEpochSecond * 1000)
old:
val lastMillis = (lastTime.state as DateTimeType).calendar.timeInMillis
new:
val lastMillis = (lastTime.state as DateTimeType).getZonedDateTime.toInstant.toEpochMilli
I think you forgot the “get” in “getZonedDateTime”? Or is both working?
This is another area that I’m not the biggest fan of the Xtend language. The short of it is you do not have to provide the “get” part of a call to any method that starts with “get”.
val DateTime dtt = new DateTimeType()
is sufficient. With no parameters it defaults to now.