Example usage for org.joda.time ReadableDuration isLongerThan

List of usage examples for org.joda.time ReadableDuration isLongerThan

Introduction

In this page you can find the example usage for org.joda.time ReadableDuration isLongerThan.

Prototype

boolean isLongerThan(ReadableDuration duration);

Source Link

Document

Is the length of this duration longer than the duration passed in.

Usage

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 .j  ava2s  .c  o m
 * <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();
}