1

Upon testing JODA time to get number of days that has been selected, it is excluding the start day.

    Date from = day1.getTime();
    Date to = day2.getTime();

    int daysBetween = Days.daysBetween(new DateTime(from), new DateTime(to)).getDays();

So if I select, December 14 - 16, it is only showing "2" as result instead of 3.

Is it safe to just "+1" the result or is there a right way to do this in JODA time?

Woppi
  • 5,303
  • 11
  • 57
  • 81

1 Answers1

2

Actually Days.daysBetween(-,-) method just subtracts the start day from the end day. If you want to get the total no of days including the start day then you must have to minus 1 from the start date.

Shashank K
  • 210
  • 3
  • 10