public Date getToDate() { if (toDate != null && toDate.getDate() != null) { return toDate.getDate(); } else { return null; } }
public Date getFromDate() { if (fromDate != null && fromDate.getDate() != null) { return fromDate.getDate(); } else { return null; } }
@Override @SuppressWarnings("unused") protected boolean validateFormLogic(UserRequest ureq) { boolean retVal = true; // datefields are valid // check complex rules involving checks over multiple elements Date fromDateVal = fromDate.getDate(); Date toDateVal = toDate.getDate(); if (!fromDate.hasError() && !toDate.hasError()) { // check valid dates // if both are set, check from < to if (fromDateVal != null && toDateVal != null) { /* * bugfix http://bugs.olat.org/jira/browse/OLAT-813 valid dates and not * empty, in easy mode we assume that Start and End date should * implement the meaning of * ----false---|S|-----|now|-TRUE---------|E|---false--->t ............. * Thus we check for Startdate < Enddate, error otherwise */ if (fromDateVal.after(toDateVal)) { fromDate.setTranslator( Util.createPackageTranslator( org.olat.course.condition.Condition.class, ureq.getLocale(), fromDate.getTranslator())); fromDate.setErrorKey("form.easy.error.bdateafteredate", null); retVal = false; } } else { if (fromDateVal == null && !fromDate.isEmpty()) { // not a correct begin date fromDate.setTranslator( Util.createPackageTranslator( org.olat.course.condition.Condition.class, ureq.getLocale(), fromDate.getTranslator())); fromDate.setErrorKey("form.easy.error.bdate", null); retVal = false; } if (toDateVal == null && !toDate.isEmpty()) { toDate.setTranslator( Util.createPackageTranslator( org.olat.course.condition.Condition.class, ureq.getLocale(), toDate.getTranslator())); toDate.setErrorKey("form.easy.error.edate", null); retVal = false; } } } return retVal; }