Java Calendar Between getDaysBetween(Calendar firstDate, Calendar lastDate)

Here you can find the source of getDaysBetween(Calendar firstDate, Calendar lastDate)

Description

Return the number of whole days between two dates

License

Open Source License

Parameter

Parameter Description
firstDate The first date
lastDate The second date

Return

The number of days' difference

Declaration

@Deprecated
public static int getDaysBetween(Calendar firstDate, Calendar lastDate) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.util.Calendar;

public class Main {
    /**//from   w ww .  j  a  v a 2  s.  co  m
     * The number of milliseconds in a day
     */
    public static final long MILLIS_PER_DAY = 86400000;

    /**
     * Return the number of whole days between two dates
     * @param firstDate The first date
     * @param lastDate The second date
     * @return The number of days' difference
     */
    @Deprecated
    public static int getDaysBetween(Calendar firstDate, Calendar lastDate) {
        long diffMillis = lastDate.getTimeInMillis() - firstDate.getTimeInMillis();
        return (int) Math.floorDiv(diffMillis, MILLIS_PER_DAY);
    }
}

Related

  1. daysBetweenCalendarDates(final Calendar firstDate, final Calendar secondDate)
  2. daysBetweenForDate(Calendar startDate, Calendar endDate)
  3. daysBetweenxX(Calendar start, Calendar end)
  4. getDaysBetween(Calendar d1, Calendar d2)
  5. getDaysBetween(Calendar d1, Calendar d2)
  6. getDaysBetween(Calendar start, Calendar end)
  7. getDaysBetween(Calendar startDate, Calendar endDate)
  8. getDaysBetween(final Calendar start, final Calendar end)
  9. getFmtCalendar(Calendar c, long betweenTimeout, StringBuilder sb)