Skip to content

Commit d597216

Browse files
authored
Merge pull request #1050 from WildMeOrg/fix-dateadded-enddate
Fix date added end of day filter in legacy Encounter Search
2 parents f7a6c39 + d341251 commit d597216

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/main/java/org/ecocean/EncounterQueryProcessor.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ public static String queryStringBuilder(HttpServletRequest request, StringBuffer
4444
String jdoqlVariableDeclaration = "";
4545
String parameterDeclaration = "";
4646
String context = "context0";
47+
long endOfDayMilliseconds = 24 * 60 * 60 * 1000 - 1;
4748

4849
context = ServletUtilities.getContext(request);
4950
Shepherd myShepherd = new Shepherd(context);
@@ -1442,7 +1443,7 @@ public static String queryStringBuilder(HttpServletRequest request, StringBuffer
14421443
long date1Millis = date1.getMillis();
14431444
long date2Millis = date2.getMillis();
14441445
// if same dateTime is set by both pickers, then add a full day of milliseconds to picker2 to cover the entire day
1445-
date2Millis += (24 * 60 * 60 * 1000 - 1);
1446+
date2Millis += endOfDayMilliseconds;
14461447

14471448
prettyPrint.append("Dates between: " +
14481449
date1.toString(ISODateTimeFormat.date()) + " and " +
@@ -1472,10 +1473,10 @@ public static String queryStringBuilder(HttpServletRequest request, StringBuffer
14721473
date2.toString(ISODateTimeFormat.date()) + "<br />");
14731474
if (filter.equals(SELECT_FROM_ORG_ECOCEAN_ENCOUNTER_WHERE)) {
14741475
filter += "((dwcDateAddedLong >= " + date1.getMillis() +
1475-
") && (dwcDateAddedLong <= " + date2.getMillis() + "))";
1476+
") && (dwcDateAddedLong <= " + (date2.getMillis()+endOfDayMilliseconds) + "))";
14761477
} else {
14771478
filter += " && ((dwcDateAddedLong >= " + date1.getMillis() +
1478-
") && (dwcDateAddedLong <= " + date2.getMillis() + "))";
1479+
") && (dwcDateAddedLong <= " + (date2.getMillis()+endOfDayMilliseconds) + "))";
14791480
}
14801481
} catch (NumberFormatException nfe) {
14811482
// do nothing, just skip on

0 commit comments

Comments
 (0)