Java Date Between betweenTwoDates(Date date1, Date date2)

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

Description

between Two Dates

License

Apache License

Declaration

public static int betweenTwoDates(Date date1, Date date2) 

Method Source Code

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

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

public class Main {
    public static int betweenTwoDates(Date date1, Date date2) {

        return (int) ((getMillis(date1) - getMillis(date2)) / (24 * 3600 * 1000));
    }/*  w w  w  .  j a v  a2 s  .  com*/

    public static long getMillis(Date date) {

        Calendar c = Calendar.getInstance();
        c.setTime(date);

        return c.getTimeInMillis();
    }
}

Related

  1. betweenDate(String from, String to)
  2. betweenHour(Date date, int hour)
  3. betweenInDay(Date date, Date start, Date end)
  4. betweenStartDateAndEndDate(Date startDate, Date endDate)
  5. betweenStrict(Date kezdet, Date datum, Date veg)
  6. daysBetween(Date d1)
  7. daysBetween(Date d1, Date d2)
  8. daysBetween(Date date1, Date date2)
  9. DaysBetween(Date date1, Date date2)