title: Scala how to get LocalDate by pattern
body: <p>I try to get <code>LocaDate</code> by format so i took this function that receive date and search for format to parse:</p>
  
  <pre><code>def getLocalDate(date: String): LocalDate = {
  
      val pattern1 = DateTimeFormatter.ofPattern("dd MMM, yyyy")
      val pattern2 = DateTimeFormatter.ofPattern("dd MMM yyyy")
      val pattern3 = DateTimeFormatter.ofPattern("yyyy-MMM-dd")
      val pattern4 = DateTimeFormatter.ofPattern("dd/MM/YYYY")
      val pattern5 = DateTimeFormatter.ISO_LOCAL_DATE
  
      val result = Try {
        LocalDate.parse(date, pattern1)
      } recover {
        case _ =&gt; LocalDate.parse(date, pattern2)
      } recover {
        case _ =&gt; LocalDate.parse(date, pattern3)
      } recover {
        case _ =&gt; LocalDate.parse(date, pattern4)
      } recover {
        case _ =&gt; LocalDate.parse(date, pattern5)
      }
  
      result.get
    }
  </code></pre>
  
  <p>Usage:</p>
  
  <pre><code>var s1 = "01/08/2010"
  getLocalDate(s1)
  </code></pre>
  
  <p>But got an error: </p>
  
  <pre><code>java.time.format.DateTimeParseException: Text '01/08/2010' could not be parsed at index 0
  </code></pre>
  
  <p>And i don;t know why and what goes wrong.</p>