org.kiwiproject.time.KiwiDurations Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of kiwi Show documentation
Show all versions of kiwi Show documentation
Kiwi is a utility library. We really like Google's Guava, and also use Apache Commons.
But if they don't have something we need, and we think it is useful, this is where we put it.
The newest version!
package org.kiwiproject.time;
import lombok.experimental.UtilityClass;
import java.time.Duration;
/**
* Utilities related to Java's {@link Duration} class.
*/
@UtilityClass
public class KiwiDurations {
/**
* Check if a {@link Duration} is positive.
*
* @param duration the duration to check
* @return true if the duration is strictly positive, otherwise false
*/
public static boolean isPositive(Duration duration) {
return !duration.isNegative() && !duration.isZero();
}
/**
* Check if a {@link Duration} is positive or zero.
*
* @param duration the duration to check
* @return true if the duration is positive or zero, otherwise false
*/
public static boolean isPositiveOrZero(Duration duration) {
return !duration.isNegative();
}
/**
* Check if a {@link Duration} is negative or zero.
*
* @param duration the duration to check
* @return true if the duration is negative or zero, otherwise false
*/
public static boolean isNegativeOrZero(Duration duration) {
return duration.isNegative() || duration.isZero();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy