Java Date Difference dayDiff(Date first, Date second)

Here you can find the source of dayDiff(Date first, Date second)

Description

day Diff

License

Open Source License

Declaration

public static int dayDiff(Date first, Date second) 

Method Source Code


//package com.java2s;
/*//from w ww .  j a va  2  s  .  c o  m
 * Copyright 2007 Sun Microsystems, Inc.
 * All rights reserved.  You may not modify, use,
 * reproduce, or distribute this software except in
 * compliance with  the terms of the License at:
 * http://developer.sun.com/berkeley_license.html
 */

import java.util.*;

public class Main {
    public static int dayDiff(Date first, Date second) {
        // returns the difference, in days, between the first
        // and second Date arguments
        long msPerDay = 1000 * 60 * 60 * 24;
        long diff = (first.getTime() / msPerDay) - (second.getTime() / msPerDay);
        Long convertLong = new Long(diff);

        return convertLong.intValue();
    }
}

Related

  1. dateDiffInDaysIgnoreTime(Date dateStart, Date dateEnd)
  2. dateDiffMonth(Date d1, Date d2)
  3. dateDiffWithNow(Calendar sDate)
  4. dayDiff(Date a, Date b)
  5. dayDiff(Date date1, Date date2)
  6. dayDiffByStartOfDay(Date a, Date b)
  7. daysDiff(Date d1, Date d2)
  8. diff(Date d1, Date d2)
  9. diff(Date date1, Date date2)