I have two dates in an org.threeten.bp.LocalDateTime
object. I need to find the difference between these two dates in terms of days.
A date-time without a time-zone in the ISO-8601 calendar system, such as 2007-12-03T10:15:30 . LocalDateTime is an immutable date-time object that represents a date-time, often viewed as year-month-day-hour-minute-second.
In Java 8, we can use Period , Duration or ChronoUnit to calculate the difference between two LocalDate or LocaldateTime . Period to calculate the difference between two LocalDate . Duration to calculate the difference between two LocalDateTime . ChronoUnit for everything.
Use org.threeten.bp.temporal.ChronoUnit.between
:
long days = ChronoUnit.DAYS.between(fromDate, toDate);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With