本文整理匯總了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;
}
示例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;
}
示例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;
}
示例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");
}
}
示例5: of
import org.joda.time.Interval; //導入方法依賴的package包/類
public static Range of(Interval interval) {
return new Range(interval.getStart(), interval.getEnd());
}
示例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;
}