I have two dates String dateOne="ddMMyyyy" String dateTwo="ddMMyyyy"
I want the difference like 2years 3months 10days
How can i do that?
I have two dates String dateOne="ddMMyyyy" String dateTwo="ddMMyyyy"
I want the difference like 2years 3months 10days
How can i do that?
If you parse those strings into LocalDate
, you can use the following line of code:
ChronoUnit.DAYS.between(firstDate, secondDate)
You can also use this method using between()
method:
public long getDaysCountBetweenDates(LocalDate dateBefore, LocalDate dateAfter) {
return DAYS.between(firstDate, secondDate);
}