If you're looking for a solution that returns proper number or days between e.g. 11/30/2014 23:59
and 12/01/2014 00:01
here's solution using Joda Time.
private int getDayDifference(long past, long current) {
DateTime currentDate = new DateTime(current);
DateTime pastDate = new DateTime(past);
return currentDate.getDayOfYear() - pastDate.getDayOfYear();
}
This implementation will return 1
as a difference in days. Most of the solutions posted here calculate difference in milliseconds between two dates. It means that 0
would be returned because there's only 2 minutes difference between these two dates.