use of jakarta.mail.search.ReceivedDateTerm in project exist by eXist-db.
the class MessageListFunctions method parseReceivedDateTerm.
private SearchTerm parseReceivedDateTerm(Node terms) throws XPathException {
SearchTerm st = null;
String value = ((Element) terms).getAttribute("date");
String format = ((Element) terms).getAttribute("format");
if (StringUtils.isEmpty(value)) {
throw (new XPathException(this, "value not specified for term with type: " + ((Element) terms).getAttribute("type")));
}
if (StringUtils.isEmpty(format)) {
throw (new XPathException(this, "format not specified for term with type: " + ((Element) terms).getAttribute("type")));
}
int cp = parseComparisonAttribute(terms);
try {
SimpleDateFormat sdf = new SimpleDateFormat(format);
Date date = sdf.parse(value);
st = new ReceivedDateTerm(cp, date);
} catch (ParseException pe) {
throw (new XPathException(this, "Cannot parse date value: " + value + ", using format: " + format + ", for term with type: " + ((Element) terms).getAttribute("type")));
}
return (st);
}
Aggregations