I wrote the following code to find the days between two dates
startDateValue = new Date(startDate);
endDateValue = new Date(endDate);
long diff = endDateValue.getTime() - startDateValue.getTime();
long seconds = diff / 1000;
long minutes = seconds / 60;
long hours = minutes / 60;
long days = (hours / 24) + 1;
Log.d("days", "" + days);
When the start and end dates are 2/3/2017 and 3/3/2017, respectively, the number of days displayed is 29. Although for the same day it shows 1. (The number of days that the vacation takes. If the person takes a vacation for one day, he must choose the same start and end date, so in this case he took a two-day vacation).
What am I doing wrong? Thank you for your time.
Note: please do not use date constructor. Check the accepted answer below. Use a simple format or Joda time. Date constructor is deprecated.