Java Calendar Different differenceInDays(Calendar date1, Calendar date2)

Here you can find the source of differenceInDays(Calendar date1, Calendar date2)

Description

difference In Days

License

Apache License

Declaration

public static long differenceInDays(Calendar date1, Calendar date2) 

Method Source Code

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

import java.util.Calendar;

public class Main {
    public static long differenceInDays(Calendar date1, Calendar date2) {
        final long msPerDay = 1000 * 60 * 60 * 24;

        final long date1Milliseconds = date1.getTime().getTime();
        final long date2Milliseconds = date2.getTime().getTime();
        final long result = (date1Milliseconds - date2Milliseconds) / msPerDay;

        return result;
    }//  w  w w  .j  ava 2  s . c  o  m
}

Related

  1. dateDiff(long dateUtilitiesUnitField, Calendar firstDate, Calendar secondDate)
  2. dateDifferenceInMin(Calendar startDate, Calendar stopDate)
  3. diff(Calendar value1, Calendar value2, int millisInCondition)
  4. diffDay(Calendar calendar, int day)
  5. diffDays(Calendar startDate, Calendar endDate)
  6. formatTimeDiff(Calendar ref, Calendar now, boolean ignoreMS)
  7. getDateDiff(Calendar c1, Calendar c2)
  8. getDateDiff(Calendar d1, Calendar d2)
  9. getDateDiff(Date d1, Date d2, int gregorianCalendarUnits)