Android Date Interval Get dayDiff(Date date1, Date date2)

Here you can find the source of dayDiff(Date date1, Date date2)


day Diff


Open Source License


public static int dayDiff(Date date1, Date date2) 

Method Source Code

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

import java.util.Date;

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

    public static int dayDiff(Date date1, Date date2) {
        long diff = date1.getTime() - date2.getTime();
        return (int) (diff / DAY);
    }//  w  ww .j a  v  a2  s  .c om


  1. calculateDiffInHours(Date date1, Date date2)
  2. calculateDiffInMilliSeconds(Date date1, Date date2)
  3. calculateDiffInMinutes(Date date1, Date date2)
  4. dateDiff(String startTime, String endTime)
  5. dateDiff(String startTime, String endTime, String format, String str)
  6. dayOffset(Date date, int offset)
  7. daysBetweenDate(Date date1, Date date2)
  8. getDiff(String startTime, String endTime)
  9. getDiff(String startTime, String endTime)