December 3, 2020, 3:15pm
After migration to OH3 a rule which used now.toDateMidnight stoped working:
val max = TE_AAUS_M3.maximumSince(now.toDateMidnight)
Although I searched a lot I could not find an equivalent replacement for this with ZonedDateTime. So far my best running solution is:
val max = TE_AAUS_M3.maximumSince(now.minusHours(24))
But this is obviously not the same. Is there any equivalent to get start time of the actual day?
Thank you for any help!
EDIT: I am using Rules DSL
December 3, 2020, 3:54pm
Ok, I meanwhile figured it out by myself. It seems to work with:
val max = TE_AAUS_M3.maximumSince(now.withHour(0))
December 3, 2020, 5:54pm
To get exactly midnight,
December 3, 2020, 9:38pm
I was wondering about exactly that…does ZonedDateTime clear “the rest” (minutes, seconds etc.) if I only specify withHour(0) or do i have to write such a verbose command to really come back to midnight exactly…
From the Java docs I would have chosen the truncatedTo method, but this seems not to be available in Rules DSL…
December 3, 2020, 9:55pm
December 3, 2020, 10:00pm
Yes, you need to set all of them.
December 3, 2020, 10:03pm
Wow, thank you very much, that’s what I was looking for! I did not find it myself, but you are right, in the docs I find:
That seems to me the best replacement for now.toDateMidnight