public int getNumberOfCommentsThisDay() { List<Comment> commentList = commentEJB.getAllComment(); Calendar today = Calendar.getInstance(); today.set(Calendar.HOUR_OF_DAY, 0); today.set(Calendar.MINUTE, 0); today.set(Calendar.SECOND, 0); today.set(Calendar.MILLISECOND, 0); List<Comment> commentsThisDay = new ArrayList<>(); for (int i = 0; i < commentList.size(); i++) { if (commentList.get(i).getCreatedAt().after(today.getTime())) { commentsThisDay.add(commentList.get(i)); } } return commentsThisDay.size(); }
public int getTotalNumberOfComments() { return commentEJB.getAllComment().size(); }