public void close() { List<Auction> allCurrentAuctions = dao.actuals(); for (Auction auction : allCurrentAuctions) { if (startedLastWeek(auction)) { try { auction.close(); total++; dao.update(auction); postman.send(auction); } catch (Exception e) { // Add logs and future counter to have the errors statistic. } } } }
private boolean startedLastWeek(Auction auction) { return daysBetween(auction.getDate(), Calendar.getInstance()) >= 7; }