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ŭ
  • 10,681
  • 20
  • 92
  • 192

2 Answers2

0

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

Math.abs(userBirthday.toEpochDay() - eventDate.toEpochDay()) >= 5
Rudziankoŭ
  • 10,681
  • 20
  • 92
  • 192
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
  • 15,272
  • 18
  • 86
  • 131