Java Date Difference DateDiff(Date startDate, Date endDate)

Here you can find the source of DateDiff(Date startDate, Date endDate)

Description

Date Diff

License

Open Source License

Declaration

public static long DateDiff(Date startDate, Date endDate) 

Method Source Code

//package com.java2s;

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

public class Main {

    public static long DateDiff(Date startDate, Date endDate) {
        long totalDate = 0;
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(startDate);//from  w w  w. jav a2  s .  c o m
        long timestart = calendar.getTimeInMillis();
        calendar.setTime(endDate);
        long timeend = calendar.getTimeInMillis();
        totalDate = (timeend - timestart) / (1000 * 60 * 60 * 24);
        return totalDate;
    }
}

Related

  1. dateDiff(Date d1, Date d2, int field)
  2. dateDiff(Date date1, Date date2)
  3. dateDiff(Date date1, Date date2)
  4. dateDiff(Date date1, Date date2)
  5. dateDiff(Date fromDate, Date toDate)
  6. dateDiff(final Date date1, final Date date2)
  7. dateDiff(int category, Date date1, Date date2)
  8. dateDiff(int interval, Date begin, Date end)
  9. dateDiff(java.util.Date a, java.util.Date b)