use of datawave.query.attributes.ValueTuple in project datawave by NationalSecurityAgency.
the class EvaluationPhaseFilterFunctions method beforeDate.
/**
* Searches for a date before end (exclusively)
*
* @param fieldValue
* A field value in the supplied format
* @param pattern
* A date format to be supplied to java.text.SimpleDateFormat
* @param end
* An end date in the supplied rangePattern format
* @param rangePattern
* A date format to be supplied to java.text.SimpleDateFormat
* @return True if the datetime occurs before the provided datetime value
*/
public static FunctionalSet<ValueTuple> beforeDate(Object fieldValue, String pattern, String end, String rangePattern) {
FunctionalSet<ValueTuple> matches = FunctionalSet.emptySet();
if (fieldValue != null) {
try {
DateFormat format = newSimpleDateFormat(pattern);
DateFormat rangeFormat = newSimpleDateFormat(rangePattern);
long lStart = 0;
long lEnd = getTime(end, rangeFormat) - 1;
if (betweenInclusive(getTime(fieldValue, format), lStart, lEnd)) {
matches = FunctionalSet.singleton(getHitTerm(fieldValue));
}
} catch (ParseException pe) {
log.error(pe.getMessage());
} catch (NumberFormatException nfe) {
log.error("Unable to numeric argument " + end + ": " + nfe.getMessage());
}
}
return matches;
}
Aggregations