Java Date Difference dateDiffInDays(Date dateStart, Date dateEnd)

Here you can find the source of dateDiffInDays(Date dateStart, Date dateEnd)

Description

computes (dateEnd - dateStart) in days

License

Apache License

Parameter

Parameter Description
dateStart the beginning of the intervalle
dateEnd the end of the inervalle

Return

the length of the intervalle in days

Declaration

public static float dateDiffInDays(Date dateStart, Date dateEnd) 

Method Source Code

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

import java.util.*;

public class Main {
    public static final long ONE_DAY_IN_MILLIS = 60 * 60 * 24 * 1000;

    /**/*from  w ww.  ja  v  a  2  s . co m*/
     * computes (dateEnd - dateStart) in days
     * @param dateStart the beginning of the intervalle
     * @param dateEnd the end of the inervalle
     * @return the length of the intervalle in days
     */
    public static float dateDiffInDays(Date dateStart, Date dateEnd) {
        return ((float) (dateEnd.getTime() - dateStart.getTime())) / ONE_DAY_IN_MILLIS;
    }
}

Related

  1. dateDiff(java.util.Date a, java.util.Date b)
  2. dateDiff(String startDate, String endDate)
  3. dateDiff(String startTime, String endTime, String format)
  4. DateDiff(String strDateBegin, String strDateEnd, int iType)
  5. dateDiffer(String time1, String time2, String formatStr)
  6. dateDiffInDaysIgnoreTime(Date dateStart, Date dateEnd)
  7. dateDiffMonth(Date d1, Date d2)
  8. dateDiffWithNow(Calendar sDate)
  9. dayDiff(Date a, Date b)