use of jakarta.mail.search.SentDateTerm in project exist by eXist-db.
the class MessageListFunctions method parseSentDateTerm.
private SearchTerm parseSentDateTerm(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 SentDateTerm(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