Java Calendar Different datediff(Calendar c1, Calendar c2)

Here you can find the source of datediff(Calendar c1, Calendar c2)

Description

datediff

License

Apache License

Declaration

public static int datediff(Calendar c1, Calendar c2) 

Method Source Code

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

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

public class Main {
    public static int datediff(Calendar c1, Calendar c2) {
        if (c1 == null || c2 == null)
            return -1;
        long r = c1.getTimeInMillis() - c2.getTimeInMillis();
        r = r / (24 * 60 * 60 * 1000);// www.  j a v a  2s. c  o  m
        return (int) r;
    }

    public static int datediff(Date c1, Date c2) {
        if (c1 == null || c2 == null)
            return -1;
        long r = c1.getTime() - c2.getTime();
        r = r / (24 * 60 * 60 * 1000);
        return (int) r;
    }
}

Related

  1. countDiffDay(Calendar c1, Calendar c2)
  2. countDiffMonth(Calendar cBegin, Calendar cEnd, boolean isRoundUp)
  3. dateDiff(int type, Calendar fromDate, Calendar toDate)
  4. dateDiff(int type, Calendar fromDate, Calendar toDate, boolean future)
  5. dateDiff(int type, Calendar fromDate, Calendar toDate, boolean future)
  6. dateDiff(long dateUtilitiesUnitField, Calendar firstDate, Calendar secondDate)