title: How do I Date format for dd MMM yyyy, as in 01 Apr 2020
body: <p>I have a pdf file where I want to know if the next line is a date, or just a string (there are two types of formats of the listing, and knowing if I've arrived at a date is important.) The trouble is, there appears to be no way to use date formatting to arrive at a date of 01 Apr 2020</p>
  
  <pre><code>LocalDate date = parseDate( "dd MMM yyyy", "01 Apr 2020" );
  </code></pre>
  
  <p>Throws ... Text '01 Apr 2020' could not be parsed at index 3</p>
  
  <pre><code>    private static LocalDate parseDate( final String format, final String s ) {
  
          final DateTimeFormatter df = DateTimeFormatter.ofPattern( format );
          LocalDate ld;   // Check if this was a legal LocalDate.
          try {
              ld = LocalDate.parse(s, df);
          } catch (java.time.format.DateTimeParseException pe) {
              System.out.println( pe.getMessage() );
              ld = null;  // This will signal an error
          }
          return ld;
      }
  </code></pre>
  
  <p>Is there really no way to parse that format of date, like a bank uses in their pdf?</p>