Java Date Difference getDayDiff(Date firstDate, Date secondDate)

Here you can find the source of getDayDiff(Date firstDate, Date secondDate)

Description

Returns the difference of two dates in days (fristDay - secondDay).

License

Open Source License

Declaration

public static int getDayDiff(Date firstDate, Date secondDate) 

Method Source Code

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

import java.util.*;

public class Main {
    /**//from   w w  w.  j ava 2  s .c o m
     * Returns the difference of two dates in days (fristDay - secondDay).
     * <p/>
     * The argument are thereby not assumed to be in any order: the names are just used in order to the ease the
     * understanding)
     */
    public static int getDayDiff(Date firstDate, Date secondDate) {
        long fristDay = (int) (firstDate.getTime() / (86400. * 1000.));
        long secondDay = (int) (secondDate.getTime() / (86400. * 1000.));

        return (int) (fristDay - secondDay);
    }
}

Related

  1. getDateDiff(String startTime, String endTime)
  2. getDateDiffDay(String begindate, String enddate)
  3. getDateDifference(String start, String end)
  4. getDateDifference(String startDateString, String endDateString)
  5. getDateDiffHour(String begindate, String enddate)
  6. getDiff(Date from, Date to)
  7. getDiffDate(String srcDate, String format, int diff)
  8. getDiffDays(Date from, Date to)
  9. getDiffDays2(Date one, Date two)