Example usage for org.joda.time Duration ZERO

List of usage examples for org.joda.time Duration ZERO

Introduction

In this page you can find the example usage for org.joda.time Duration ZERO.

Prototype

Duration ZERO

To view the source code for org.joda.time Duration ZERO.

Click Source Link

Document

Constant representing zero millisecond duration

Usage

From source file:kr.debop4j.timeperiod.calendars.DateDiff.java

License:Apache License

public boolean isEmpty() {
    return difference.isEqual(Duration.ZERO);
}

From source file:kr.debop4j.timeperiod.DateTimeSet.java

License:Apache License

@Override
public boolean isMoment() {
    Duration duration = getDuration();
    return (duration != null) && (duration.compareTo(Duration.ZERO) == 0);
}

From source file:kr.debop4j.timeperiod.test.samples.TimeBlockPeriodRelationTestData.java

License:Apache License

public TimeBlockPeriodRelationTestData(DateTime start, DateTime end, Duration duration) {

    Guard.shouldBe(duration.compareTo(Duration.ZERO) >= 0,
            "duration? 0??? ?  .");

    setReference(new TimeBlock(start, end, true));

    DateTime beforeEnd = start.minus(duration);
    DateTime beforeStart = beforeEnd.minus(reference.getDuration());
    DateTime insideStart = start.plus(duration);
    DateTime insideEnd = end.minus(duration);
    DateTime afterStart = end.plus(duration);
    DateTime afterEnd = afterStart.plus(reference.getDuration());

    after = new TimeBlock(beforeStart, beforeEnd, true);
    startTouching = new TimeBlock(beforeStart, start, true);
    startInside = new TimeBlock(beforeStart, insideStart, true);
    insideStartTouching = new TimeBlock(start, afterStart, true);
    enclosingStartTouching = new TimeBlock(start, insideEnd, true);
    enclosing = new TimeBlock(insideStart, insideEnd, true);
    enclosingEndTouching = new TimeBlock(insideStart, end, true);
    exactMatch = new TimeBlock(start, end, true);
    inside = new TimeBlock(beforeStart, afterEnd, true);
    insideEndTouching = new TimeBlock(beforeStart, end, true);
    endInside = new TimeBlock(insideEnd, afterEnd, true);
    endTouching = new TimeBlock(end, afterEnd, true);
    before = new TimeBlock(afterStart, afterEnd, true);

    allPeriods.add(reference);//from   w ww .ja  va 2  s.co  m
    allPeriods.add(after);
    allPeriods.add(startTouching);
    allPeriods.add(startInside);
    allPeriods.add(insideStartTouching);
    allPeriods.add(enclosingStartTouching);
    allPeriods.add(enclosing);
    allPeriods.add(enclosingEndTouching);
    allPeriods.add(exactMatch);
    allPeriods.add(inside);
    allPeriods.add(insideEndTouching);
    allPeriods.add(endInside);
    allPeriods.add(endTouching);
    allPeriods.add(before);
}

From source file:kr.debop4j.timeperiod.test.samples.TimeRangePeriodRelationTestData.java

License:Apache License

public TimeRangePeriodRelationTestData(DateTime start, DateTime end, Duration duration) {
    Guard.shouldBe(duration.compareTo(Duration.ZERO) >= 0,
            "duration? 0??? ?  .");

    setReference(new TimeRange(start, end, true));

    DateTime beforeEnd = start.minus(duration);
    DateTime beforeStart = beforeEnd.minus(reference.getDuration());
    DateTime insideStart = start.plus(duration);
    DateTime insideEnd = end.minus(duration);
    DateTime afterStart = end.plus(duration);
    DateTime afterEnd = afterStart.plus(reference.getDuration());

    after = new TimeRange(beforeStart, beforeEnd, true);
    startTouching = new TimeRange(beforeStart, start, true);
    startInside = new TimeRange(beforeStart, insideStart, true);
    insideStartTouching = new TimeRange(start, afterStart, true);
    enclosingStartTouching = new TimeRange(start, insideEnd, true);
    enclosing = new TimeRange(insideStart, insideEnd, true);
    enclosingEndTouching = new TimeRange(insideStart, end, true);
    exactMatch = new TimeRange(start, end, true);
    inside = new TimeRange(beforeStart, afterEnd, true);
    insideEndTouching = new TimeRange(beforeStart, end, true);
    endInside = new TimeRange(insideEnd, afterEnd, true);
    endTouching = new TimeRange(end, afterEnd, true);
    before = new TimeRange(afterStart, afterEnd, true);

    allPeriods.add(reference);//from ww w .ja v  a  2s .co m
    allPeriods.add(after);
    allPeriods.add(startTouching);
    allPeriods.add(startInside);
    allPeriods.add(insideStartTouching);
    allPeriods.add(enclosingStartTouching);
    allPeriods.add(enclosing);
    allPeriods.add(enclosingEndTouching);
    allPeriods.add(exactMatch);
    allPeriods.add(inside);
    allPeriods.add(insideEndTouching);
    allPeriods.add(endInside);
    allPeriods.add(endTouching);
    allPeriods.add(before);
}

From source file:kr.debop4j.timeperiod.TimeInterval.java

License:Apache License

@Override
public ITimeInterval copy() {
    return copy(Duration.ZERO);
}

From source file:kr.debop4j.timeperiod.TimePeriodBase.java

License:Apache License

/**
 * Sets duration./*from   w  w w . jav  a  2s.co m*/
 *
 * @param duration the duration
 */
public void setDuration(Duration duration) {
    assert duration.getMillis() >= Duration.ZERO
            .getMillis() : "Duration? ? 0 ?  .";
    if (hasStart())
        end = start.plus(duration);
}

From source file:kr.debop4j.timeperiod.TimePeriodBase.java

License:Apache License

/**
 * Copy i time period.
 *
 * @return the i time period
 */
public ITimePeriod copy() {
    return copy(Duration.ZERO);
}

From source file:kr.debop4j.timeperiod.TimePeriodBase.java

License:Apache License

@Override
public ITimePeriod copy(Duration offset) {

    log.trace(" [{}]? offset[{}]?  ? ...", this, offset);

    if (offset == Duration.ZERO)
        return new TimeRange(this);

    return new TimeRange(hasStart() ? start.plus(offset.getMillis()) : start,
            hasEnd() ? end.plus(offset.getMillis()) : end, readonly);
}

From source file:kr.debop4j.timeperiod.TimePeriodBase.java

License:Apache License

@Override
public void move(Duration offset) {
    if (offset == Duration.ZERO)
        return;/*from  w w  w  .  j  av a 2s .  c  o m*/
    assertMutable();

    log.trace("[{}]? offset[{}]? ??.", this, offset);

    if (hasStart())
        start = start.plus(offset.getMillis());
    if (hasEnd())
        end = end.plus(offset.getMillis());
}

From source file:net.cpollet.jixture.fixtures.generator.field.DateSequence.java

License:Apache License

/**
 * Build a sequence that will return values between {@code start} and {@code end} (inclusive) with an increment of
 * {@code increment}. For instance, in://from w ww .ja  va2s  .c  om
 * <pre>
 *     s1 = new DateSequence(
 *        new DateTime(1, 1, 1, 0, 0, 0),
 *        new DateTime(1, 1, 3, 0, 0, 0),
 *        new Duration(24 * 60 * 60 * 1000)
 *     );
 *     s1 = new DateSequence(
 *        new DateTime(1, 1, 1, 0, 0, 0),
 *        new DateTime(1, 1, 5, 0, 0, 0),
 *        new Duration(2 * 24 * 60 * 60 * 1000)
 *     );
 * </pre>
 * {@code s1} will generate the following dates: {@code 1-1-1T0:0:0}, {@code 1-1-2T0:0:0}, {@code 1-1-3T0:0:0} and
 * {@code s2} will generate {@code 1-1-1T0:0:0}, {@code 1-1-3T0:0:0}, {@code 1-1-5T0:0:0}.
 *
 * @param start first value in sequence, inclusive.
 * @param stop last element in sequence, inclusive.
 * @param duration increment.
 *
 * @throws java.lang.IllegalArgumentException if start is less than stop or if increment is less than or equal to
 * 0ms.
 */
public DateSequence(DateTime start, DateTime stop, ReadableDuration duration) {
    AssertionUtils.assertTrue(duration.isLongerThan(Duration.ZERO), "duration must be > 0ms");
    AssertionUtils.assertTrue(!stop.isBefore(start), "stop must be >= start");

    this.stop = stop;
    this.start = start;
    this.duration = duration;

    reset();
}