]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
HM-5: Added AFTER Month Day Year and AFTER Day Month Year support
authorcesarvh <cesarv.h@berkeley.edu>
Wed, 17 Oct 2018 22:08:43 +0000 (15:08 -0700)
committercesarvh <cesarv.h@berkeley.edu>
Tue, 19 Mar 2019 19:39:56 +0000 (12:39 -0700)
services/structureddate/structureddate/src/main/java/org/collectionspace/services/structureddate/DateUtils.java
services/structureddate/structureddate/src/test/resources/test-dates.yaml

index 36c961373e8718c308fe12fdc07797827d5d8d24..2adc2d8c82d61ed666f8d3288618e3ece68f187a 100644 (file)
@@ -1,7 +1,5 @@
 package org.collectionspace.services.structureddate;
 
-import java.util.Calendar;
-
 import org.joda.time.Chronology;
 import org.joda.time.DateTime;
 import org.joda.time.DateTimeConstants;
@@ -12,6 +10,7 @@ import org.joda.time.Years;
 import org.joda.time.chrono.GJChronology;
 import org.joda.time.format.DateTimeFormat;
 import org.joda.time.format.DateTimeFormatter;
+import org.joda.time.LocalDate;
 
 public class DateUtils {
        private static final DateTimeFormatter monthFormatter = DateTimeFormat.forPattern("MMMM");
@@ -1109,7 +1108,7 @@ public class DateUtils {
        
        /**
         * Calculates the latest date that may be considered to be "after"
-        * a given date range.
+        * a given date range. We define "after" as the current date.
         * 
         * @param startDate The first date in the range
         * @param endDate   The last date in the range
@@ -1117,7 +1116,12 @@ public class DateUtils {
         */
        public static Date getLatestAfterDate(Date startDate, Date endDate) {
                // TODO
-               return null;
+               LocalDate localDate = new LocalDate();
+               Integer year = (Integer) localDate.getYear();
+               Integer month = (Integer) localDate.getMonthOfYear();
+               Integer dayOfMonth = (Integer) localDate.getDayOfMonth();
+               return new Date(year, month, dayOfMonth, Date.DEFAULT_ERA);
+
        }
 
        public static int getYearsBetween(Date startDate, Date endDate) {
index 53cbbbbaf7a41b3fd665fcb96695608f00e90745..f3f0b07b1e99a9b5d71964a463092e23168759db 100644 (file)
                                          latestDate:         [2017,  6, 10, CE]
 
 
-  "after 13 april 1995":
-                                         earliestSingleDate: [1995,  4, 13, CE]
-                                         latestDate:         [2018,  10, 17, CE]
+  "after 13 april 1995":
+                                         earliestSingleDate: [1995,  4, 13, CE]
+                                         latestDate:         [2018,  10, 17, CE]
 
   "unknown":
                                          earliestSingleDate: []
+  "after april 13 1995":
+                                         earliestSingleDate: [1995,  4, 13, CE]
+                                         latestDate:         [2018,  10, 17, CE]
 
 
 # -------------------------------------------------------------------------------------------------------