Example usage for org.joda.time Duration isLongerThan

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

Introduction

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

Prototype

public boolean isLongerThan(ReadableDuration duration) 

Source Link

Document

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

Usage

From source file:rcrr.reversi.Clock.java

License:Open Source License

/**
 * Returns a new clock object generated subtracting the delta value from
 * the specified player remaining clock time.
 * <p>//w  ww.j  a  v a2  s. com
 * When the delta parameter is greather than the player's actual time
 * the updated value is set to zero.
 * <p>
 * Parameter {@code player} must be not {@code null}.
 * Parameter {@code delta} must be not {@code null}, and must be not negative.
 *
 * @param  player the player from which to take away the specified time
 * @param  delta  the amount of time in milliseconds to subtract from the
 *                player's clock time
 * @return        a new updated clock
 * @throws NullPointerException     if the player or delta parameter is null
 * @throws IllegalArgumentException if the delta parameter is negative.
 */
public Clock decrement(final Player player, final Duration delta) {
    if (player == null) {
        throw new NullPointerException("Parameter player connot be null");
    }
    if (delta == null) {
        throw new NullPointerException("Parameter delta connot be null.");
    }
    if (delta.isShorterThan(Duration.ZERO)) {
        throw new IllegalArgumentException("Parameter delta cannot be negative.");
    }
    final Duration actual = this.durations.get(player);
    final Duration updated = (actual.isLongerThan(delta)) ? actual.minus(delta) : Duration.ZERO;
    return valueOf(set(player, updated));
}

From source file:silvertrout.plugins.packagetracker.Package.java

License:Open Source License

/**
 * Check if package have expired, either if it was created and not updated for a while
 * //from   w w w . j a v a2s . c om
 * @return true if package have expired
 */
public boolean expired() {
    Duration timeSinceUpdated = new Duration(new DateTime(created), null);
    Duration timeSinceCreated = new Duration(new DateTime(updated), null);

    return timeSinceUpdated.isLongerThan(Duration.standardDays(PACKAGE_TTL))
            && timeSinceCreated.isLongerThan(Duration.standardDays(PACKAGE_TTL));
}