Java Calendar Between daysBetween(Calendar startTime, Calendar endTime)

Here you can find the source of daysBetween(Calendar startTime, Calendar endTime)

Description

days Between

License

Apache License

Declaration

public static int daysBetween(Calendar startTime, Calendar endTime) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.util.Calendar;

public class Main {
    public static int daysBetween(Calendar startTime, Calendar endTime) {
        if (startTime == null) {
            throw new IllegalArgumentException("startTime is null");
        }//  ww w.ja va2s .  c o m
        if (endTime == null) {
            throw new IllegalArgumentException("endTime is null");
        }
        if (startTime.compareTo(endTime) > 0) {
            throw new IllegalArgumentException("endTime is before the startTime");
        }
        return (int) ((endTime.getTimeInMillis() - startTime.getTimeInMillis()) / (1000 * 60 * 60 * 24));
    }
}

Related

  1. daysBetween(Calendar early, Calendar late)
  2. daysBetween(Calendar early, Calendar late)
  3. daysBetween(Calendar fromCalendar, Calendar untilCalendar)
  4. daysBetween(Calendar fromDate, Calendar toDate)
  5. daysBetween(Calendar start, Calendar end)
  6. daysBetween(final Calendar cal1, final Calendar cal2)
  7. daysBetween(final Calendar startDate, final Calendar endDate)
  8. daysBetween(final Calendar startDate, final Calendar endDate)
  9. daysBetweenCalendarDates(final Calendar firstDate, final Calendar secondDate)