TimeUnit.MILLISECONDS


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 ");
  }
}
Home 
  Java Book 
    Thread Conncurrent  

TimeUnit:
  1. The TimeUnit Enumeration
  2. TimeUnit: DAYS
  3. TimeUnit.MILLISECONDS
  4. TimeUnit.SECONDS
  5. TimeUnit: sleep(long timeout)
  6. TimeUnit: toDays(long duration)
  7. TimeUnit: toHours(long duration)
  8. TimeUnit: toMinutes(long duration)