当前位置: 首页>>代码示例>>Java>>正文


Java Interval.getEnd方法代码示例

本文整理汇总了Java中org.joda.time.Interval.getEnd方法的典型用法代码示例。如果您正苦于以下问题:Java Interval.getEnd方法的具体用法?Java Interval.getEnd怎么用?Java Interval.getEnd使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.joda.time.Interval的用法示例。


在下文中一共展示了Interval.getEnd方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: mergeSlots

import org.joda.time.Interval; //导入方法依赖的package包/类
public static List<Interval> mergeSlots(List<Interval> slots) {
    if (slots.size() <= 1) {
        return slots;
    }
    slots.sort(Comparator.comparing(AbstractInterval::getStart));
    boolean isMerged = false;
    List<Interval> merged = new ArrayList<>();
    merged.add(slots.get(0));
    for (int i = 1; i < slots.size(); ++i) {
        Interval first = slots.get(i - 1);
        Interval second = slots.get(i);
        if (!second.getStart().isAfter(first.getEnd())) {
            merged.remove(i - 1);
            DateTime laterEnding = first.getEnd().isAfter(second.getEnd()) ? first.getEnd() : second.getEnd();
            merged.add(new Interval(first.getStart(), laterEnding));
            isMerged = true;
        } else {
            merged.add(second);
        }
    }
    if (isMerged) {
        merged = mergeSlots(merged);
    }
    // Nothing to merge anymore
    return merged;
}
 
开发者ID:CSCfi,项目名称:exam,代码行数:27,代码来源:DateTimeUtils.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.getEnd方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。