static public LocalDate getParsedDateOrNull ( String text , DateTimeFormatter displayFormatterADStrict , DateTimeFormatter displayFormatterBCStrict , ArrayList < DateTimeFormatter > parsingFormattersStrict , Locale formatLocale ) { if ( text == null || text . trim ( ) . isEmpty ( ) ) { return null ; } text = text . trim ( ) . toLowerCase ( ) ; LocalDate parsedDate = null ; if ( parsedDate == null ) { try { parsedDate = LocalDate . parse ( text , displayFormatterADStrict ) ; } catch ( Exception ex ) { } } if ( parsedDate == null ) { try { // Note: each parse attempt must have its own try/catch block. parsedDate = LocalDate . parse ( text , displayFormatterBCStrict ) ; } catch ( Exception ex ) { } } for ( int i = 0 ; ( ( parsedDate == null ) && ( i < parsingFormattersStrict . size ( ) ) ) ; ++ i ) { try { parsedDate = LocalDate . parse ( text , parsingFormattersStrict . get ( i ) ) ; } catch ( Exception ex ) { } } return parsedDate ; }
getParsedDateOrNull This takes text from the date picker text field and tries to parse it into a java . time . LocalDate instance . If the text cannot be parsed this will return null .