summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorshawn.f.cook2012-01-09 17:15:29 (EST)
committer Ryan D. Brooks2012-01-09 17:15:29 (EST)
commitdf90162eaeeaeb3219f42af8ba258acd9011c066 (patch)
treea437639edd092bcd51e6af53d5701d3294a523c0
parentd79ca96b74c490ce62d37714336170cb07d9e738 (diff)
downloadorg.eclipse.osee-df90162eaeeaeb3219f42af8ba258acd9011c066.zip
org.eclipse.osee-df90162eaeeaeb3219f42af8ba258acd9011c066.tar.gz
org.eclipse.osee-df90162eaeeaeb3219f42af8ba258acd9011c066.tar.bz2
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 a2c307f..273f9ce 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();
+ }
}