Android Date Interval Get DaysBetween(Date beginDate, Date endDate)

Here you can find the source of DaysBetween(Date beginDate, Date endDate)

Description

Days Between

Declaration

public static int DaysBetween(Date beginDate, Date endDate) 

Method Source Code

//package com.java2s;

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

public class Main {
    public static int DaysBetween(Date beginDate, Date endDate) {
        Calendar cal = Calendar.getInstance();
        cal.setTime(beginDate);//from  ww  w .ja va  2 s .c om
        long beginTime = cal.getTimeInMillis();
        cal.setTime(endDate);
        long EndTime = cal.getTimeInMillis();
        long between_days = (EndTime - beginTime) / (1000 * 3600 * 24);
        return Integer.parseInt(String.valueOf(between_days));
    }
}

Related

  1. calculateDiffInDays(Date date1, Date date2)
  2. calculateDiffInHours(Date date1, Date date2)
  3. calculateDiffInMilliSeconds(Date date1, Date date2)
  4. calculateDiffInMinutes(Date date1, Date date2)