public boolean isTextValid ( String text ) { // If the text is null or the settings are null, return false. if ( text == null || settings == null ) { return false ; } // If the text is empty, return the value of allowEmptyDates. text = text . trim ( ) ; if ( text . isEmpty ( ) ) { return settings . getAllowEmptyDates ( ) ; } // Try to get a parsed date. LocalDate parsedDate = InternalUtilities . getParsedDateOrNull ( text , settings . getFormatForDatesCommonEra ( ) , settings . getFormatForDatesBeforeCommonEra ( ) , settings . getFormatsForParsing ( ) , settings . getLocale ( ) ) ; // If the date could not be parsed, return false. if ( parsedDate == null ) { return false ; } // If the date is vetoed, return false. DateVetoPolicy vetoPolicy = settings . getVetoPolicy ( ) ; if ( InternalUtilities . isDateVetoed ( vetoPolicy , parsedDate ) ) { return false ; } // The date is valid, so return true. return true ; }
isTextValid This function can be used to see if the supplied text represents a valid date according to the settings of this date picker .