Code example for Date

Methods: compareTo

0
            fieldName = "";
        } else { 
            fieldName = ": " + fieldName;
        } 
 
        Date now = new Date(System.currentTimeMillis());
 
        try { 
            int yearVal = Integer.parseInt(year);
            int monthVal = Integer.parseInt(month);
            int dayVal = Integer.parseInt(day);
            Calendar cal = new GregorianCalendar(yearVal, monthVal - 1, dayVal);
            java.util.Date givenDate = cal.getTime();
 
            if (now.compareTo(givenDate) <= 0) {
                errors.add("date", new ActionError("error.date.infuture", fieldName));
            } 
        } catch (NumberFormatException e) {
            /* 
             *  handled in validateDate