/** * Is this seconds instance less than the specified number of seconds. * * @param other the other period, null means zero * @return true if this seconds instance is less than the specified one */ public boolean isLessThan(Seconds other) { if (other == null) { return getValue() < 0; } return getValue() < other.getValue(); }
/** * Gets the number of seconds that this period represents. * * @return the number of seconds in the period */ public int getSeconds() { return getValue(); }
/** * Is this seconds instance greater than the specified number of seconds. * * @param other the other period, null means zero * @return true if this seconds instance is greater than the specified one */ public boolean isGreaterThan(Seconds other) { if (other == null) { return getValue() > 0; } return getValue() > other.getValue(); }
/** * Gets the number of seconds that this period represents. * * @return the number of seconds in the period */ public int getSeconds() { return getValue(); }
/** * Is this seconds instance greater than the specified number of seconds. * * @param other the other period, null means zero * @return true if this seconds instance is greater than the specified one */ public boolean isGreaterThan(Seconds other) { if (other == null) { return getValue() > 0; } return getValue() > other.getValue(); }
/** * Is this seconds instance less than the specified number of seconds. * * @param other the other period, null means zero * @return true if this seconds instance is less than the specified one */ public boolean isLessThan(Seconds other) { if (other == null) { return getValue() < 0; } return getValue() < other.getValue(); }
/** * Gets this instance as a String in the ISO8601 duration format. * <p> * For example, "PT4S" represents 4 seconds. * * @return the value as an ISO8601 string */ @ToString public String toString() { return "PT" + String.valueOf(getValue()) + "S"; }
/** * Resolves singletons. * * @return the singleton instance */ private Object readResolve() { return Seconds.seconds(getValue()); }
/** * Gets this instance as a String in the ISO8601 duration format. * <p> * For example, "PT4S" represents 4 seconds. * * @return the value as an ISO8601 string */ @ToString public String toString() { return "PT" + String.valueOf(getValue()) + "S"; }
/** * Resolves singletons. * * @return the singleton instance */ private Object readResolve() { return Seconds.seconds(getValue()); }
/** * Returns a new instance with the specified number of seconds added. * <p> * This instance is immutable and unaffected by this method call. * * @param seconds the amount of seconds to add, may be negative, null means zero * @return the new period plus the specified number of seconds * @throws ArithmeticException if the result overflows an int */ public Seconds plus(Seconds seconds) { if (seconds == null) { return this; } return plus(seconds.getValue()); }
/** * Returns a new instance with the specified number of seconds taken away. * <p> * This instance is immutable and unaffected by this method call. * * @param seconds the amount of seconds to take away, may be negative, null means zero * @return the new period minus the specified number of seconds * @throws ArithmeticException if the result overflows an int */ public Seconds minus(Seconds seconds) { if (seconds == null) { return this; } return minus(seconds.getValue()); }
/** * Converts this period in seconds to a period in minutes assuming a * 60 second minute. * <p> * This method allows you to convert between different types of period. * However to achieve this it makes the assumption that all minutes are * 60 seconds long. * This may not be true for some unusual chronologies. However, it is included * as it is a useful operation for many applications and business rules. * * @return a period representing the number of minutes for this number of seconds */ public Minutes toStandardMinutes() { return Minutes.minutes(getValue() / DateTimeConstants.SECONDS_PER_MINUTE); }
/** * Converts this period in seconds to a period in hours assuming a * 60 minute hour and 60 second minute. * <p> * This method allows you to convert between different types of period. * However to achieve this it makes the assumption that all hours are * 60 minutes long and all minutes are 60 seconds long. * This may not be true for some unusual chronologies. However, it is included * as it is a useful operation for many applications and business rules. * * @return a period representing the number of hours for this number of seconds */ public Hours toStandardHours() { return Hours.hours(getValue() / DateTimeConstants.SECONDS_PER_HOUR); }
/** * Returns a new instance with the specified number of seconds taken away. * <p> * This instance is immutable and unaffected by this method call. * * @param seconds the amount of seconds to take away, may be negative, null means zero * @return the new period minus the specified number of seconds * @throws ArithmeticException if the result overflows an int */ public Seconds minus(Seconds seconds) { if (seconds == null) { return this; } return minus(seconds.getValue()); }
/** * Returns a new instance with the seconds multiplied by the specified scalar. * <p> * This instance is immutable and unaffected by this method call. * * @param scalar the amount to multiply by, may be negative * @return the new period multiplied by the specified scalar * @throws ArithmeticException if the result overflows an int */ public Seconds multipliedBy(int scalar) { return Seconds.seconds(FieldUtils.safeMultiply(getValue(), scalar)); }
/** * Returns a new instance with the seconds value negated. * * @return the new period with a negated value * @throws ArithmeticException if the result overflows an int */ public Seconds negated() { return Seconds.seconds(FieldUtils.safeNegate(getValue())); }
/** * Returns a new instance with the seconds value negated. * * @return the new period with a negated value * @throws ArithmeticException if the result overflows an int */ public Seconds negated() { return Seconds.seconds(FieldUtils.safeNegate(getValue())); }
/** * Returns a new instance with the seconds multiplied by the specified scalar. * <p> * This instance is immutable and unaffected by this method call. * * @param scalar the amount to multiply by, may be negative * @return the new period multiplied by the specified scalar * @throws ArithmeticException if the result overflows an int */ public Seconds multipliedBy(int scalar) { return Seconds.seconds(FieldUtils.safeMultiply(getValue(), scalar)); }
/** * Returns a new instance with the specified number of seconds added. * <p> * This instance is immutable and unaffected by this method call. * * @param seconds the amount of seconds to add, may be negative * @return the new period plus the specified number of seconds * @throws ArithmeticException if the result overflows an int */ public Seconds plus(int seconds) { if (seconds == 0) { return this; } return Seconds.seconds(FieldUtils.safeAdd(getValue(), seconds)); }