java.util.concurrent.TimeUnit can be used to convert between milliseconds and days : TimeUnit « Development « Java Tutorial






import java.util.Calendar;
import java.util.concurrent.TimeUnit;

public class Main {

  public static long getDifference(Calendar a, Calendar b, TimeUnit units) {
    return units.convert(b.getTimeInMillis() - a.getTimeInMillis(), TimeUnit.MILLISECONDS);
  }

  public static void main(String[] args) {
    Calendar first = Calendar.getInstance();
    first.set(2008, Calendar.AUGUST, 1);
    Calendar second = Calendar.getInstance();

    System.out.println(getDifference(first, second, TimeUnit.DAYS) + " day(s) between ");
  }
}








6.19.TimeUnit
6.19.1.Using new methods in TimeUnit
6.19.2.java.util.concurrent.TimeUnit can be used to convert between milliseconds and days