Java Calendar Between daysBetweenForDate(Calendar startDate, Calendar endDate)

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

Description

days Between For Date

License

Apache License

Declaration

public static long daysBetweenForDate(Calendar startDate, Calendar endDate) 

Method Source Code

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

import java.util.Calendar;

public class Main {
    public static long daysBetweenForDate(Calendar startDate, Calendar endDate) {
        Calendar date = (Calendar) startDate.clone();
        date.set(Calendar.HOUR_OF_DAY, 0);
        date.set(Calendar.MINUTE, 0);
        date.set(Calendar.SECOND, 0);
        date.set(Calendar.MILLISECOND, 0);

        endDate.set(Calendar.HOUR_OF_DAY, 0);
        endDate.set(Calendar.MINUTE, 0);
        endDate.set(Calendar.SECOND, 0);
        endDate.set(Calendar.MILLISECOND, 0);

        long daysBetween = 0;
        while (date.before(endDate)) {
            date.add(Calendar.DAY_OF_MONTH, 1);
            daysBetween++;// w w  w  .ja  va  2 s.com
        }
        return daysBetween;
    }
}

Related

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