package org.collectionspace.services.structureddate;
-import java.util.Calendar;
-
import org.joda.time.Chronology;
import org.joda.time.DateTime;
import org.joda.time.DateTimeConstants;
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");
/**
* 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
*/
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) {
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]
# -------------------------------------------------------------------------------------------------------