Java Calendar Between daysBetween(final Calendar startDate, final Calendar endDate)

Here you can find the source of daysBetween(final Calendar startDate, final Calendar endDate)

Description

days Between

License

Apache License

Declaration

public static long daysBetween(final Calendar startDate, final Calendar endDate) 

Method Source Code


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

import java.util.Calendar;
import java.util.Date;

public class Main {
    public static long daysBetween(final Calendar startDate, final Calendar endDate) {
        long days = 0;
        while (endDate.after(startDate)) {
            endDate.add(Calendar.DATE, -1);
            ++days;/*from  w w w  . j  a v a 2  s.com*/
        }

        return days;
    }

    public static long daysBetween(final Date startDate, final Date endDate) {
        Calendar start = Calendar.getInstance();
        Calendar end = Calendar.getInstance();

        start.setTime(startDate);
        end.setTime(endDate);

        return daysBetween(start, end);
    }
}

Related

  1. daysBetween(Calendar fromDate, Calendar toDate)
  2. daysBetween(Calendar start, Calendar end)
  3. daysBetween(Calendar startTime, Calendar endTime)
  4. daysBetween(final Calendar cal1, final Calendar cal2)
  5. daysBetween(final Calendar startDate, final Calendar endDate)
  6. daysBetweenCalendarDates(final Calendar firstDate, final Calendar secondDate)
  7. daysBetweenForDate(Calendar startDate, Calendar endDate)
  8. daysBetweenxX(Calendar start, Calendar end)
  9. getDaysBetween(Calendar d1, Calendar d2)