Java Calendar Between daysBetween(Calendar fromDate, Calendar toDate)

Here you can find the source of daysBetween(Calendar fromDate, Calendar toDate)

Description

days Between

License

Open Source License

Declaration

public static long daysBetween(Calendar fromDate, Calendar toDate) 

Method Source Code

//package com.java2s;

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

public class Main {
    public static long daysBetween(Calendar fromDate, Calendar toDate) {
        return Math.round((toDate.getTimeInMillis() - fromDate.getTimeInMillis()) / (1000 * 60 * 60 * 24));
    }//from   www. j  a v a2  s .c  o m

    public static long daysBetween(Date fromDate, Date toDate) {
        return daysBetween(getCalendar(fromDate), getCalendar(toDate));
    }

    public static Calendar getCalendar(Date date) {

        Calendar calendar = Calendar.getInstance();
        calendar.setTime(date);

        return calendar;
    }
}

Related

  1. daysBetween(Calendar early, Calendar late)
  2. daysBetween(Calendar early, Calendar late)
  3. daysBetween(Calendar fromCalendar, Calendar untilCalendar)
  4. daysBetween(Calendar start, Calendar end)
  5. daysBetween(Calendar startTime, Calendar endTime)
  6. daysBetween(final Calendar cal1, final Calendar cal2)
  7. daysBetween(final Calendar startDate, final Calendar endDate)