public String getLastEnrolledExecutionYear() { if (getStudent() == null) { return ""; } List<ExecutionYear> enrolmentsExecutionYears = new ArrayList<ExecutionYear>(getEnrolmentsExecutionYears(getStudent())); Collections.sort(enrolmentsExecutionYears, ExecutionYear.REVERSE_COMPARATOR_BY_YEAR); ExecutionYear lastEnrolledExecutionYear = null; if (enrolmentsExecutionYears.isEmpty()) { return ""; } if (enrolmentsExecutionYears.size() == 1 && ExecutionYear.readCurrentExecutionYear() .equals(enrolmentsExecutionYears.iterator().next())) { return ""; } else if (ExecutionYear.readCurrentExecutionYear() .equals(enrolmentsExecutionYears.iterator().next())) { lastEnrolledExecutionYear = enrolmentsExecutionYears.get(1); } else { lastEnrolledExecutionYear = enrolmentsExecutionYears.iterator().next(); } return ((Integer) lastEnrolledExecutionYear.getBeginCivilYear()).toString(); }