0

I have two LocalDate objects. I want to find out how many days there are between two events:

if(Math.abs(userBirthday - eventDate) <= 5)
    // give discount

Do you have any suggestions how to do it in a most sophisticated way?

Rudziankoŭ
  • 9,663
  • 16
  • 80
  • 173

2 Answers2

0

I found solution, please confirm that it's correct way of doing this:

Math.abs(userBirthday.toEpochDay() - eventDate.toEpochDay()) >= 5
Rudziankoŭ
  • 9,663
  • 16
  • 80
  • 173
0

From memory of JodaTime you can do something like this

Days.daysBetween(startLocalTime, endLocalTime).getDays()

(not 100% on this Im afraid - Im on a machine without a compiler)

RNJ
  • 14,884
  • 18
  • 80
  • 129