17

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.

Tunaki
  • 132,869
  • 46
  • 340
  • 423
gaurav
  • 189
  • 2
  • 6

1 Answers1

44

Use org.threeten.bp.temporal.ChronoUnit.between:

long days = ChronoUnit.DAYS.between(fromDate, toDate);  
wero
  • 32,544
  • 3
  • 59
  • 84
  • 1
    Just a note - if you want time difference in minutes/seconds, you need to use `LocalDateTime` and not `LocalDate`, otherwise you get an exception. – RominaV Jun 25 '20 at 20:52