It’s very simple:

import java.util.Date;

public class DateUtils {

private static final long MILISECONDS_PER_DAY = 24 * 60 * 60 * 1000;

public static int getDaysBetweenDates(Date startDate, Date endDate) {
long diff = endDate.getTime() – startDate.getTime();
int days = (int) Math.floor(diff / MILISECONDS_PER_DAY);
return Math.abs(days);
}
}

Advertisements