當前位置: 首頁>>代碼示例>>Java>>正文


Java Interval.getStart方法代碼示例

本文整理匯總了Java中org.joda.time.Interval.getStart方法的典型用法代碼示例。如果您正苦於以下問題:Java Interval.getStart方法的具體用法?Java Interval.getStart怎麽用?Java Interval.getStart使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.joda.time.Interval的用法示例。


在下文中一共展示了Interval.getStart方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: gatherSuitableSlots

import org.joda.time.Interval; //導入方法依賴的package包/類
protected Collection<Interval> gatherSuitableSlots(ExamRoom room, LocalDate date, Integer examDuration) {
    Collection<Interval> examSlots = new ArrayList<>();
    // Resolve the opening hours for room and day
    List<ExamRoom.OpeningHours> openingHours = room.getWorkingHoursForDate(date);
    if (!openingHours.isEmpty()) {
        // Get suitable slots based on exam duration
        for (Interval slot : allSlots(openingHours, room, date)) {
            DateTime beginning = slot.getStart();
            DateTime openUntil = getEndOfOpeningHours(beginning, openingHours);
            if (!beginning.plusMinutes(examDuration).isAfter(openUntil)) {
                DateTime end = beginning.plusMinutes(examDuration);
                examSlots.add(new Interval(beginning, end));
            }
        }
    }
    return examSlots;
}
 
開發者ID:CSCfi,項目名稱:exam,代碼行數:18,代碼來源:CalendarController.java

示例2: findGaps

import org.joda.time.Interval; //導入方法依賴的package包/類
public static List<Interval> findGaps(List<Interval> reserved, Interval searchInterval) {
    List<Interval> gaps = new ArrayList<>();
    DateTime searchStart = searchInterval.getStart();
    DateTime searchEnd = searchInterval.getEnd();
    if (hasNoOverlap(reserved, searchStart, searchEnd)) {
        gaps.add(searchInterval);
        return gaps;
    }
    // create a sub-list that excludes interval which does not overlap with
    // searchInterval
    List<Interval> subReservedList = removeNonOverlappingIntervals(reserved, searchInterval);
    DateTime subEarliestStart = subReservedList.get(0).getStart();
    DateTime subLatestEnd = subReservedList.get(subReservedList.size() - 1).getEnd();

    // in case the searchInterval is wider than the union of the existing
    // include searchInterval.start => earliestExisting.start
    if (searchStart.isBefore(subEarliestStart)) {
        gaps.add(new Interval(searchStart, subEarliestStart));
    }

    // get all the gaps in the existing list
    gaps.addAll(getExistingIntervalGaps(subReservedList));

    // include latestExisting.end => searchInterval.end
    if (searchEnd.isAfter(subLatestEnd)) {
        gaps.add(new Interval(subLatestEnd, searchEnd));
    }
    return gaps;

}
 
開發者ID:CSCfi,項目名稱:exam,代碼行數:31,代碼來源:DateTimeUtils.java

示例3: sliceIntervals

import org.joda.time.Interval; //導入方法依賴的package包/類
/**
 * Slices the intervals into smaller intervals of the timeGrain duration.
 *
 * @param interval  interval to be sliced
 * @param timeGrain  size of the slice
 *
 * @return list of intervals obtained by slicing the larger interval
 *
 * @throws java.lang.IllegalArgumentException if the interval is not an even multiple of the time grain
 */
public static List<Interval> sliceIntervals(Interval interval, TimeGrain timeGrain) {
    // TODO: Refactor me to use a Period
    DateTime intervalEnd = interval.getEnd();
    DateTime sliceStart = interval.getStart();
    DateTime periodStart = timeGrain.roundFloor(sliceStart);

    if (!sliceStart.equals(periodStart)) {
        LOG.info("Interval {} is not aligned to TimeGrain {} starting {}", interval, timeGrain, periodStart);
        throw new IllegalArgumentException("Interval must be aligned to the TimeGrain starting " + periodStart);
    }

    List<Interval> intervalSlices = new ArrayList<>();
    while (sliceStart.isBefore(intervalEnd)) {
        // Find the end of the next slice
        DateTime sliceEnd = DateTimeUtils.addTimeGrain(sliceStart, timeGrain);

        // Make the next slice
        Interval slicedInterval = new Interval(sliceStart, sliceEnd);

        // Make sure that our slice is fully contained within our interval
        if (!interval.contains(slicedInterval)) {
            LOG.info("Interval {} is not a multiple of TimeGrain {}", interval, timeGrain);
            throw new IllegalArgumentException("Interval must be a multiple of the TimeGrain");
        }

        // Add the slice
        intervalSlices.add(slicedInterval);

        // Move the slicer forward
        sliceStart = sliceEnd;
    }
    LOG.debug("Sliced interval {} into {} slices of {} grain", interval, intervalSlices.size(), timeGrain);

    return intervalSlices;
}
 
開發者ID:yahoo,項目名稱:fili,代碼行數:46,代碼來源:DateTimeUtils.java

示例4: IntervalPeriodIterator

import org.joda.time.Interval; //導入方法依賴的package包/類
/**
 * Constructor.
 *
 * @param period  The period to divide the interval by
 * @param baseInterval  The raw interval which is to be divided
 */
public IntervalPeriodIterator(@NotNull ReadablePeriod period, Interval baseInterval) {
    this.period = period;
    intervalStart = baseInterval.getStart();
    intervalEnd = baseInterval.getEnd();
    position = 0;
    currentPosition = boundaryAt(0);

    // Chronology accepts null periods, we must not do so or this iterator is non-terminating
    if (period == null) {
        throw new IllegalArgumentException("Period cannot be null");
    }
}
 
開發者ID:yahoo,項目名稱:fili,代碼行數:19,代碼來源:IntervalPeriodIterator.java

示例5: of

import org.joda.time.Interval; //導入方法依賴的package包/類
public static Range of(Interval interval) {
    return new Range(interval.getStart(), interval.getEnd());
}
 
開發者ID:dmart28,項目名稱:gcplot,代碼行數:4,代碼來源:Range.java

示例6: setLrpPeriod

import org.joda.time.Interval; //導入方法依賴的package包/類
public Builder setLrpPeriod(@Nullable Interval lrpPeriod) {
  getInstance().lrpPeriodStart = (lrpPeriod == null ? null : lrpPeriod.getStart());
  getInstance().lrpPeriodEnd = (lrpPeriod == null ? null : lrpPeriod.getEnd());
  return this;
}
 
開發者ID:google,項目名稱:nomulus,代碼行數:6,代碼來源:Registry.java


注:本文中的org.joda.time.Interval.getStart方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。