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?
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?
I found solution, please confirm that it's correct way of doing this:
Math.abs(userBirthday.toEpochDay() - eventDate.toEpochDay()) >= 5
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)