From 73d380fb76f2c707c93fe37c1c0d605bb42b6203 Mon Sep 17 00:00:00 2001 From: Seth Ladygo Date: Fri, 13 Jul 2018 17:18:34 -0700 Subject: [PATCH] EPLHelpers: add date comparison functions --- src/main/java/EPLHelpers.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/main/java/EPLHelpers.java b/src/main/java/EPLHelpers.java index 96377a5..fd3b6ae 100644 --- a/src/main/java/EPLHelpers.java +++ b/src/main/java/EPLHelpers.java @@ -1,6 +1,7 @@ import org.joda.time.DateTime; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.joda.time.DateTimeComparator; public class EPLHelpers { @@ -10,4 +11,20 @@ public class EPLHelpers { public static int getHour(DateTime date) { return date.getHourOfDay(); } + + /** + * Compare two times and return true if the first is earlier than + * the second. + */ + public static boolean earlierThan(DateTime a, DateTime b) { + return DateTimeComparator.getInstance().compare(a, b) < 0; + } + + /** + * Compare two times and return true if the first is later than + * the second. + */ + public static boolean laterThan(DateTime a, DateTime b) { + return DateTimeComparator.getInstance().compare(a, b) > 0; + } }