Get how many days between two date.

@param date1 date to be tested.
@param date2 date to be tested.
@return how many days between two date.
182469
public static long subDays(final Date date1, final Date date2) {

    return subTime(date1, date2, DatePeriod.DAY);
  }
126854
public static int getWeek(Date date) {
        CALENDAR.setTime(date);
        return CALENDAR.get(Calendar.DAY_OF_WEEK);
    }
749189
public static int getNumberOfDays(Date first, Date second)
      {
          Calendar c = Calendar.getInstance();
          int result = 0;
          int compare = first.compareTo(second);
          if (compare > 0) return 0;
          if (compare == 0) return 1;

          c.setTime(first);
          int firstDay = c.get(Calendar.DAY_OF_YEAR);
          int firstYear = c.get(Calendar.YEAR);
          int firstDays = c.getActualMaximum(Calendar.DAY_OF_YEAR);

          c.setTime(second);
          int secondDay = c.get(Calendar.DAY_OF_YEAR);
          int secondYear = c.get(Calendar.YEAR);

          // if dates in the same year
          if (firstYear == secondYear)
          {
              result = secondDay-firstDay+1;
          }

          // different years
          else
          {
              // days from the first year
              result += firstDays - firstDay + 1;

              // add days from all years between the two dates years
              for (int i = firstYear+1; i< secondYear; i++)
              {
                  c.set(i,0,0);
                  result += c.getActualMaximum(Calendar.DAY_OF_YEAR);
              }

              // days from last year
              result += secondDay;
          }

          return result;
      }
1006386
public static function dateDiff($Date1, $Date2)
    {
        $DateList1=explode("-", $Date1);
        $DateList2=explode("-", $Date2);
        $d1=mktime(0, 0, 0, $DateList1[1], $DateList1[2], $DateList1[0]);
        $d2=mktime(0, 0, 0, $DateList2[1], $DateList2[2], $DateList2[0]);
        $Days=round(($d1-$d2)/3600/24);
        return $Days;
    }
1142784
public static long getDayDifference(Date startDate, Date endDate) {
		long startTime = startDate.getTime();
		long endTime = endDate.getTime();
		long diffTime = endTime - startTime;
		long diffDays = TimeUnit.MILLISECONDS.toDays(diffTime);
		return diffDays;
	}
1081017
public static boolean isSameDay(@NotNull final Date date1, @NotNull final Date date2) {
		return DateUtils.isSameDay(date1, date2);
	}
901858
public static boolean isSameMonth(final Date date1, final Date date2) {
        final Calendar cal1 = Calendar.getInstance();
        cal1.setTime(date1);

        final Calendar cal2 = Calendar.getInstance();
        cal2.setTime(date2);

        return cal1.get(Calendar.ERA) == cal2.get(Calendar.ERA)
                && cal1.get(Calendar.YEAR) == cal2.get(Calendar.YEAR)
                && cal1.get(Calendar.MONTH) == cal2.get(Calendar.MONTH);
    }
615232
public static int days(EvaluationContext ctx, Object endDate, Object startDate) {
        return datedif(ctx, startDate, endDate, "d");
    }
655738
def days_range(first=None, second=None, wipe=False):
    
    _first, _second = parse(first), parse(second)
    (_start, _end) = (_second, _first) if _first > _second else (_first, _second)
    days_between = (_end - _start).days
    date_list = [_end - datetime.timedelta(days=x) for x in range(0, days_between + 1)]
    if wipe and len(date_list) >= 2:
        date_list = date_list[1:-1]
    return date_list
631954
public static function diff($date1, $date2, $type = 'days', $round = true) {
		$result = strtotime($date2) - strtotime($date1);
		switch ($type) {
			case 'days':
				$result = $result / 86400;
				break;
			case 'abs days':
				$result = abs($result / 86400);
				break;
			case 'seconds':
				return $result;
				break;
			case 'abs seconds':
				return abs($result);
				break;
		}
		// rounding
		if ($round) {
			$result = (int) round($result);
		}
		return $result;
	}
42459
public static Date getDateOfSecondsBack(final int secondsBack, final Date date) {

    return dateBack(Calendar.SECOND, secondsBack, date);
  }
390438
public int getDayDifference(long first, long second) {

        Calendar firstDay = getStartOfDay(first);
        Calendar secondDay = getStartOfDay(second);
        int result = 0;
        if (first >= second) {
            while (firstDay.after(secondDay)) {
                firstDay.add(Calendar.DAY_OF_MONTH, -1);
                result += 1;
            }
        } else {
            while (secondDay.after(firstDay)) {
                secondDay.add(Calendar.DAY_OF_MONTH, -1);
                result -= 1;
            }
        }
        return result;
    }
856667
public boolean checkDate(Date date) {
		Calendar calendar = Calendar.getInstance();
		calendar.setTime(date);
		calendar.set(Calendar.HOUR_OF_DAY, 0);
		calendar.set(Calendar.MINUTE, 0);
		calendar.set(Calendar.SECOND, 0);
		calendar.set(Calendar.MILLISECOND, 0);

		Calendar minCal = Calendar.getInstance();
		minCal.setTime(minSelectableDate);
		minCal.set(Calendar.HOUR_OF_DAY, 0);
		minCal.set(Calendar.MINUTE, 0);
		minCal.set(Calendar.SECOND, 0);
		minCal.set(Calendar.MILLISECOND, 0);

		Calendar maxCal = Calendar.getInstance();
		maxCal.setTime(maxSelectableDate);
		maxCal.set(Calendar.HOUR_OF_DAY, 0);
		maxCal.set(Calendar.MINUTE, 0);
		maxCal.set(Calendar.SECOND, 0);
		maxCal.set(Calendar.MILLISECOND, 0);

		return !(calendar.before(minCal) || calendar.after(maxCal));
	}
828776
public static Date plusDays(Date date, int days) {
		return plus(date, days, DateTimeField.DAY);
	}
569871
public static Date calculatePastDate(int days) {
        final Calendar cal = Calendar.getInstance();
        cal.add(Calendar.DATE, -days);

        return cal.getTime();
    }
1138871
public static LocalDate minDate(final LocalDate date0,
            final LocalDate date1) {
        if (date1 == null) {
            return date0;
        }
        if (date0 == null) {
            return date1;
        }
        if (date1.isBefore(date0)) {
            return date1;
        } else {
            return date0;
        }
    }
1223220
function (date1, date2) {
                return date1.getHours() === date2.getHours() &&
                    date1.getMinutes() === date2.getMinutes();
            }