I want to fetch mails that are received in the last 1 hour. I checked it here -
java imap fetch messages since a date
and tried the following -
DateTime current = new DateTime();
DateTime oneHourLess = current.minusHours(1);
SearchTerm olderThan = new ReceivedDateTerm(ComparisonTerm.LT, current.toDate());
SearchTerm newerThan = new ReceivedDateTerm(ComparisonTerm.GT, oneHourLess.toDate());
SearchTerm andTerm = new AndTerm(olderThan, newerThan);
Message totalMess[] = inbox.search(andTerm);
But i get no mails since the ReceivedDateTerm does not take time into consideration.
Is there any way out how to do this?