public int getHoursByCategory(Date begin, Date end) {  List<TeacherLegalRegimen> list = new ArrayList<TeacherLegalRegimen>(); for (TeacherLegalRegimen teacherLegalRegimen : this.getLegalRegimens()) { if (teacherLegalRegimen.belongsToPeriod(begin, end)) { list.add(teacherLegalRegimen); } }
public int getHoursByCategory(Date begin, Date end) {  List<TeacherLegalRegimen> list = getAllLegalRegimensBelongsToPeriod(begin, end);
    public int getHoursByCategory(Date begin, Date end) {        List<TeacherLegalRegimen> list = new ArrayList<TeacherLegalRegimen>();        for (TeacherLegalRegimen teacherLegalRegimen : this.getLegalRegimens()) {            if (teacherLegalRegimen.belongsToPeriod(begin, end)) {                list.add(teacherLegalRegimen);            }        }        if (list.isEmpty()) {            return 0;        } else {            Collections.sort(list, new BeanComparator("beginDate"));            return list.get(list.size() -1).getLessonHours();        }    }