Claus Ibsen created CAMEL-27199:
-----------------------------------
Summary: camel-mail - searchTerm date pattern uses SS
(milliseconds) instead of ss
Key: CAMEL-27199
URL: https://issues.apache.org/jira/browse/CAMEL-27199
Project: Camel
Issue Type: Bug
Components: camel-mail
Reporter: Claus Ibsen
The fixed-date form of the {{searchTerm.fromSentDate}}, {{toSentDate}},
{{fromReceivedDate}} and {{toReceivedDate}} options is parsed with the pattern
{{yyyy-MM-dd HH:mm:SS}}. In {{SimpleDateFormat}}, {{SS}} is milliseconds, not
seconds. So the seconds of the date are read as milliseconds and the seconds
become 0.
h3. How to reproduce
{noformat}
imaps://host?username=...&searchTerm.fromSentDate=2026-11-18 14:30:45
{noformat}
The search term is built with {{2026-11-18 14:30:00.045}} instead of
{{14:30:45}}. With POP3 (where the search runs on the client) an email sent at
14:30:10 is therefore matched although it is before the given time. The
{{now-24h}} form is not affected.
h3. Where
*
{{components/camel-mail/src/main/java/org/apache/camel/component/mail/MailConverters.java}}:
{{NOW_DATE_FORMAT = "yyyy-MM-dd HH:mm:SS"}}, used by
{{toSearchTerm(SimpleSearchTerm)}} for the four date options.
* The javadoc of {{SimpleSearchTerm}} documents the same wrong pattern.
h3. Suggested fix
Use {{yyyy-MM-dd HH:mm:ss}} in {{MailConverters}} and in the
{{SimpleSearchTerm}} javadoc, and add a unit test with non-zero seconds.
Optionally document the fixed-date format in mail-component.adoc (only
{{now-24h}} is shown today).
h3. Related, docs only
{{MailConsumer.getMaxNumberOfMessages()}} uses {{fetchSize}} when it is 0 or
more, and only falls back to {{maxMessagesPerPoll}} when {{fetchSize}} is -1
(the default). So {{maxMessagesPerPoll}} has no effect once {{fetchSize}} is
set. The "Polling Optimization" section of mail-component.adoc names both
options but does not say which one wins; it would help to say so in the docs
and in the {{fetchSize}} option description.
Found while adding options to the mail Kamelets of the Kamelet catalog: the
date search options were left out because of the pattern.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)