Date now = new Date();
Date validFrom;
Date validTo;
Timestamp lastview;
Systemmessage sm = null;
while (messageIterator.hasNext()) {
sm = messageIterator.next();
validFrom = sm.getValidfrom();
validTo = sm.getValidto();
if (sm.getLanguageid().equals(currentUser.getLanguageid())
&& validFrom.before(now)) {
if (null == validTo || validTo.after(now)) {
// no validto date, or valid to date after now
lastview = currentUser.getTslastviewedsystemmessage();
if (null == lastview || lastview.before(validFrom)
|| lastview.before(sm.getTsupdated())) {
// not seen any message
// or last seen before validfrom date
// or last view before message last updated
return true;
}