public boolean isMessageTooOld(Account account, Message message, String context) throws MessagingException { if (message.getSentDate() == null) { log.warn( String.format("we have a message with no sent date for %s, allowing message", context)); return false; } else if (account.getRegister_time() == null) { log.warn( String.format( "we are process an account with no register time. this behavior is not understood yet %s, we will accept this message", context)); return false; } else { boolean messageTooOld = (System.currentTimeMillis() - message.getSentDate().getTime()) > 1000l * 60 * 60 * 24 * emailDaysCutoff; if (messageTooOld) { log.warn( String.format( "msgNum=%d, message is too old, sentDate=%s, discarding, for %s", message.getMessageNumber(), message.getSentDate(), context)); } return messageTooOld; } }