protected void updateDateValidated ( PageElement pageElement , String dateType , String date ) throws TechnicalException , FailureException { logger . debug ( "updateDateValidated with elementName={}, dateType={} and date={}" , pageElement , dateType , date ) ; final DateFormat formatter = new SimpleDateFormat ( Constants . DATE_FORMAT ) ; final Date today = Calendar . getInstance ( ) . getTime ( ) ; try { final Date valideDate = formatter . parse ( date ) ; if ( "any" . equals ( dateType ) ) { logger . debug ( "update Date with any date: {}" , date ) ; updateText ( pageElement , date ) ; } else if ( formatter . format ( today ) . equals ( date ) && ( "future" . equals ( dateType ) || "today" . equals ( dateType ) ) ) { logger . debug ( "update Date with today" ) ; updateText ( pageElement , date ) ; } else if ( valideDate . after ( Calendar . getInstance ( ) . getTime ( ) ) && ( "future" . equals ( dateType ) || "future_strict" . equals ( dateType ) ) ) { logger . debug ( "update Date with a date after today: {}" , date ) ; updateText ( pageElement , date ) ; } else { new Result . Failure <> ( date , Messages . format ( Messages . getMessage ( Messages . FAIL_MESSAGE_UNEXPECTED_DATE ) , Messages . getMessage ( Messages . DATE_GREATER_THAN_TODAY ) ) , true , pageElement . getPage ( ) . getCallBack ( ) ) ; } } catch ( final ParseException e ) { new Result . Failure <> ( e . getMessage ( ) , Messages . format ( Messages . getMessage ( Messages . FAIL_MESSAGE_WRONG_DATE_FORMAT ) , pageElement , date ) , false , pageElement . getPage ( ) . getCallBack ( ) ) ; } }
Update a html input text value with a date .