@Override
    public void setAsText(String text) throws IllegalArgumentException {
        if (this.allowEmpty && !StringUtils.hasText(text)) {
            // Treat empty String as null value.
            setValue(null);
        } else if (text != null
                && this.exactDateLength >= 0
                && text.length() != this.exactDateLength) {
            throw new IllegalArgumentException(
                    "Could not parse date: it is not exactly"
                            + this.exactDateLength
                            + "characters long");
        } else {
            setValue(this.dateFormat.parseDateTime(text).toDateMidnight());
        }
    }
@ Override public void setAsText ( String text ) throws IllegalArgumentException { if ( this . allowEmpty && ! StringUtils . hasText ( text ) ) { setValue ( null ) ; } else if ( text != null && this . exactDateLength >= 0 && text . length ( ) != this . exactDateLength ) { throw new IllegalArgumentException ( "Could not parse date: it is not exactly" + this . exactDateLength + "characters long" ) ; } else { setValue ( this . dateFormat . parseDateTime ( text ) . toDateMidnight ( ) ) ; } }
Parse the Date from the given text, using the specified DateFormat.