Java Day Between getDiffDays(Date date1, Date date2)

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

Description

get Diff Days

License

Open Source License

Declaration

public static int getDiffDays(Date date1, Date date2) 

Method Source Code

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

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

public class Main {
    private static long MILLIS_ONE_DATE = 1000 * 3600 * 24;

    public static int getDiffDays(Date date1, Date date2) {
        Calendar c = Calendar.getInstance();
        c.setTime(date1);//from   w  w  w . ja va 2  s.  c om
        long time1 = c.getTimeInMillis();

        c.setTime(date2);
        long time2 = c.getTimeInMillis();
        long between_days = (time2 - time1) / MILLIS_ONE_DATE;

        return Integer.parseInt(String.valueOf(between_days));

    }
}

Related

  1. getDaysBetween(Date startDate, Date endDate)
  2. getDaysBetweenDate(Date begin, Date end)
  3. getDaysDiff(Date startDate, Date endDate)
  4. getDaysDifference(final Date begin, final Date end)
  5. getDiffBetweenQuarter(Date latestDate, Date current)
  6. getDiffDays(String startDate, String endDate)
  7. getDifferDays(Date d1, Date d2)
  8. getDifferDays(String date1, String date2)
  9. getDifference(Date d1, Date d2)