title: Check the date format of string if it's according to required format or not
body: <p>I have the same question asked <a href="https://stackoverflow.com/questions/20231539/java-check-the-date-format-of-current-string-is-according-to-required-format-or">here</a> in Java,
  is it possible in swift?</p>
  
  <pre><code>func stringToDate(str: String) -&gt; Date{
  
      let dateFormatter = DateFormatter()
      dateFormatter.dateFormat = "dd/MM/yyyy"
  
      //check validation of str 
  
      return date
  }
  </code></pre>