Reputation: 24472
Given two OffsetDateTime
s we can calculate te number of days with:
DAYS.between(createdDateTime, finishDateTime)
This returns an absolute value of days with the difference between: 2020-03-15T10:51:24.608+00:00
and 2020-03-17T09:36:17.001+00:00
being 1.
However I need to get the exact difference including decimals, something like 1.9xxxx or so in this case. How could this be done?
Upvotes: 1
Views: 458
Reputation: 24472
I was looking for an out-of-the-box solution but as Michael pointed out in the comments something like this works perfectly:
(ChronoUnit.HOURS.between(createdDateTime, finishedDateTime) / 24.0)
Upvotes: 2