public boolean isTextValid ( String text ) { // If the text is null, return false. if ( text == null ) { return false ; } // If the text is empty, return the value of allowEmptyTimes. text = text . trim ( ) ; if ( text . isEmpty ( ) ) { return settings . getAllowEmptyTimes ( ) ; } // Try to get a parsed time. LocalTime parsedTime = InternalUtilities . getParsedTimeOrNull ( text , settings . getFormatForDisplayTime ( ) , settings . getFormatForMenuTimes ( ) , settings . formatsForParsing , settings . getLocale ( ) ) ; // If the time could not be parsed, return false. if ( parsedTime == null ) { return false ; } // If the time is vetoed, return false. TimeVetoPolicy vetoPolicy = settings . getVetoPolicy ( ) ; if ( InternalUtilities . isTimeVetoed ( vetoPolicy , parsedTime ) ) { return false ; } // The time is valid, so return true. return true ; }
isTextValid This function can be used to see if the supplied text represents a valid time according to the settings of this time picker .