获得指定日期区间内的年份和季节<br>

@param startDate 起始日期（包含）
@param endDate 结束日期（包含）
@return 季度列表 ，元素类似于 20132
@since 4.1.15
161544
public static LinkedHashSet<String> yearAndQuarter(long startDate, long endDate) {
		LinkedHashSet<String> quarters = new LinkedHashSet<>();
		final Calendar cal = calendar(startDate);
		while (startDate <= endDate) {
			// 如果开始时间超出结束时间，让结束时间为开始时间，处理完后结束循环
			quarters.add(yearAndQuarter(cal));

			cal.add(Calendar.MONTH, 3);
			startDate = cal.getTimeInMillis();
		}

		return quarters;
	}
976161
public static List<LocalDate> untilDays(String startDate, String endDate, String pattern) {
        return untilDays(parse(startDate, pattern), parse(endDate, pattern));
    }
327351
public static function formatted_dates($startObj, $endObj)
    {

        //Checking if end date is set
        $endDateIsset = true;
        if (isset($endObj->value)) {
            $endDateIsset = false;
        }

        $startTime = strtotime($startObj->value);
        $endTime = strtotime($endObj->value);

        $startMonth = date('M', $startTime);
        $startDayOfMonth = $startObj->DayOfMonth(true);
        $str = $startMonth . ' ' . $startDayOfMonth;

        if (date('Y-m-d', $startTime) == date('Y-m-d', $endTime)) {
            //one date - str. has already been written
        } else {
            //two dates

            if ($endDateIsset) {
                $endMonth = date('M', $endTime);
                $endDayOfMonth = $endObj->DayOfMonth(true);

                if ($startMonth == $endMonth) {
                    $str .= ' - ' . $endDayOfMonth;
                } else {
                    $str .= ' - ' . $endMonth . ' ' . $endDayOfMonth;
                }
            }
        }
        return $str;
    }
36594
public static SimpleInterval<Date> between(
        Date start,
        Date end
    ) {

        return OLD_DATE_FACTORY.between(start, end);

    }
439790
public static long getDaysBetweenIgnoreTime(Date startDate, Date endDate) {
        startDate = getRoundedDay(startDate);
        endDate = getNextDay(endDate);
        return getBetweenDate(startDate, endDate);
    }
1098988
public static int getMonthSpan(Date begin, Date end) {
        Calendar beginCal = new GregorianCalendar();
        beginCal.setTime(begin);
        Calendar endCal = new GregorianCalendar();
        endCal.setTime(end);
        int m = (endCal.get(Calendar.MONTH)) - (beginCal.get(Calendar.MONTH));
        int y = (endCal.get(Calendar.YEAR)) - (beginCal.get(Calendar.YEAR));
        return y * 12 + m;
    }
275532
public static java.sql.Date rollMonths(java.util.Date startDate, int months) {
        return rollDate(startDate, Calendar.MONTH, months);
    }
669161
public static long between(Date beginDate, Date endDate, DateUnit unit) {
		return between(beginDate, endDate, unit, true);
	}
1350088
public static boolean isBetween(@NotNull final Date date, @NotNull final Date start, @NotNull final Date end) {
		if (date == null || start == null || end == null || start.after(end)) {
			throw new IllegalArgumentException("some date parameters is null or dateBein after dateEnd");
		}
		return !date.before(start) && !date.after(end);
	}
321724
@Override
	public double getDaycount(LocalDate startDate, LocalDate endDate) {
		if(startDate.isAfter(endDate)) {
			return -getDaycount(endDate,startDate);
		}

		int startDateDay 	= startDate.getDayOfMonth();
		int startDateMonth 	= startDate.getMonthValue();
		int startDateYear 	= startDate.getYear();

		int endDateDay 		= endDate.getDayOfMonth();
		int endDateMonth 	= endDate.getMonthValue();
		int endDateYear 	= endDate.getYear();


		// Check if we have last day of February
		boolean isStartDateLastDayOfFebruary = (startDateMonth == Month.FEBRUARY.getValue() && startDateDay == startDate.lengthOfMonth());
		boolean isEndDateLastDayOfFebruary = (endDateMonth == Month.FEBRUARY.getValue() && endDateDay == endDate.lengthOfMonth());

		// Last day of February and 31st of a month are both treated as "30".
		if(isStartDateLastDayOfFebruary || startDateDay == 31) {
			startDateDay = 30;
		}
		if((isEndDateLastDayOfFebruary && !isTreatEndDateAsTerminationDate) || endDateDay == 31) {
			endDateDay = 30;
		}

		return (endDateYear - startDateYear) * 360.0 + (endDateMonth - startDateMonth) * 30.0 + (endDateDay - Math.min(startDateDay, 30.0));
	}
1244310
public function getParticipationsByDayByRangeDate($startDate = '', $endDate = '')
    {
        $em = $this->getServiceManager()->get('doctrine.entitymanager.orm_default');
        $emConfig = $em->getConfiguration();
        $emConfig->addCustomDatetimeFunction('DATE', '\DoctrineExtensions\Query\Mysql\Date');

        $startDateTime = \DateTime::createFromFormat('d/m/Y', $startDate);
        $endDateTime = \DateTime::createFromFormat('d/m/Y', $endDate);

        if ($startDate != '' && $endDate != '') {
            $dateRange = "(e.created_at >='" . $startDateTime->format('Y-m-d') . " 0:0:0' AND e.created_at <= '" . $endDateTime->format('Y-m-d') . " 23:59:59')";
        } elseif ($startDate == '' && $endDate != '') {
            $dateRange = "e.created_at <= '" . $endDateTime->format('Y-m-d') . " 23:59:59'";
        } elseif ($startDate != '' && $endDate == '') {
            $dateRange = "e.created_at >='" . $startDateTime->format('Y-m-d') . " 0:0:0'";
        } else {
            $dateRange = "e.created_at IS NOT NULL";
        }

        $query = $em->createQuery('
            SELECT DATE(e.created_at) as date, COUNT(e.id) as qty FROM PlaygroundGame\Entity\Entry e
			WHERE ' . $dateRange . '
            AND e.active=0
            GROUP BY date
        ');
        $result = $query->getResult();
        return $result;
    }
34012
public static Date getRandomDate(Date begin, Date end) {
		return getRandomDate(begin, end, r);
	}
215823
LocalDate endDate() {
        int ordinal = ordinal(eraValue);
        JapaneseEra[] eras = values();
        if (ordinal >= eras.length - 1) {
            return LocalDate.MAX;
        }
        return eras[ordinal + 1].startDate().minusDays(1);
    }
424964
public java.util.Date getStart()
   {
      if (childNode.getTextValueForPatternName("start") != null) {
         return XMLDate.toDate(childNode.getTextValueForPatternName("start"));
      }
      return null;
   }
163814
public static function countMonthBetweenDate($startDate, $endDate)
    {
    	$d1 = strtotime($startDate);
		$d2 = strtotime($endDate);
		$min_date = min($d1, $d2);
		$max_date = max($d1, $d2);
		$i = 0;

		while (($min_date = strtotime("+1 MONTH", $min_date)) <= $max_date) {
		    $i++;
		}
		echo $i;
    }
724054
public static function initDatesInRange($start_date, $end_date, $daysDifference = 1){
        $dates_in_range = [];
        $begin = new DateTime($start_date);
        $end = new DateTime($end_date);
        $endModify = $end->modify( '+'.$daysDifference.' day' ); 

        $interval = new DateInterval('P'.$daysDifference.'D');
        $daterange = new DatePeriod($begin, $interval ,$endModify);

        foreach($daterange as $date){
            $dates_in_range[$date->getTimestamp()] = $date->format("Y-m-d");
        }
        return $dates_in_range;
    }
507995
public static long getTwoDaysBetweenNumber(String startDate, String endDate, Format format) {
        SimpleDateFormat localFormat = (SimpleDateFormat) format;
        long day = 0;
        try {
            java.util.Date startDay = localFormat.parse(startDate);
            java.util.Date endDay = localFormat.parse(endDate);
            day = (endDay.getTime() - startDay.getTime()) / (24 * 60 * 60 * 1000);
        } catch (Exception e) {
            return 0;
        }
        return day;
    }