use of edu.uci.ics.texera.api.exception.DataflowException in project textdb by TextDB.
the class ComparableMatcher method compareDate.
private boolean compareDate(Tuple inputTuple) throws DataflowException {
LocalDate date = inputTuple.getField(predicate.getAttributeName(), DateField.class).getValue();
String compareToString = predicate.getCompareToValue().toString();
// try to parse the input as date string first
try {
LocalDate compareToDate = LocalDate.parse(compareToString);
return compareValues(date, compareToDate, predicate.getComparisonType());
} catch (DateTimeParseException e) {
// if it fails, then try to parse as date time string
try {
LocalDateTime compareToDateTime = LocalDateTime.parse(compareToString);
return compareValues(date, compareToDateTime.toLocalDate(), predicate.getComparisonType());
} catch (DateTimeParseException e2) {
throw new DataflowException("Unable to parse date or time: " + compareToString);
}
}
}
Aggregations