Bearing the risk of being redundant, I would like to know how one can subtract 2 date values and store the result which should be in number of days into an integer. I am using Java for this exercise.
If you have two LocalDate
s, you can use:
longs days = ChronoUnit.DAYS.between(date1, date2);
Note that Period::getDays
does something different: for a period of one year and one day, Period::getDays
will return 1, not 366!