Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorshawn.f.cook2012-01-09 22:15:29 +0000
committerRyan D. Brooks2012-01-09 22:15:29 +0000
commitdf90162eaeeaeb3219f42af8ba258acd9011c066 (patch)
treea437639edd092bcd51e6af53d5701d3294a523c0
parentd79ca96b74c490ce62d37714336170cb07d9e738 (diff)
downloadorg.eclipse.osee-df90162eaeeaeb3219f42af8ba258acd9011c066.tar.gz
org.eclipse.osee-df90162eaeeaeb3219f42af8ba258acd9011c066.tar.xz
org.eclipse.osee-df90162eaeeaeb3219f42af8ba258acd9011c066.zip
feature[bgz_368752]: Add method DateUtil.getMondayBefore()
-rw-r--r--plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/util/DateUtil.java26
1 files changed, 26 insertions, 0 deletions
diff --git a/plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/util/DateUtil.java b/plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/util/DateUtil.java
index a2c307fcf09..273f9ce5fd0 100644
--- a/plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/util/DateUtil.java
+++ b/plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/util/DateUtil.java
@@ -240,4 +240,30 @@ public class DateUtil {
return weeks;
}
+ /**
+ * @param date Any date
+ * @return The date that is the Monday before the date. If the provided date is Monday then it will be returned
+ * as-is.
+ */
+ public static Date getMondayBefore(Date date) {
+ Calendar cal = Calendar.getInstance();
+ cal.setTime(date);
+ while (cal.get(Calendar.DAY_OF_WEEK) != Calendar.MONDAY) {
+ cal.add(Calendar.DATE, -1);
+ }
+ return cal.getTime();
+ }
+
+ /**
+ * @param date Any date
+ * @return The date that is the Monday after the date. If the provided date is Monday then it will be returned as-is.
+ */
+ public static Date getMondayAfter(Date date) {
+ Calendar cal = Calendar.getInstance();
+ cal.setTime(date);
+ while (cal.get(Calendar.DAY_OF_WEEK) != Calendar.MONDAY) {
+ cal.add(Calendar.DATE, 1);
+ }
+ return cal.getTime();
+ }
}

Back to the top