title: Transform date string to another format in Swift
body: <p>I'm a beginner in Swift and I'm getting a date from a JSON snippet in string format, yyyy-MM-dd. For example:</p>
  
  <pre><code>2017-09-20
  </code></pre>
  
  <p>How do I display it in dd/MM/yyyy format?</p>
  
  <pre><code>20/09/2017
  </code></pre>
  
  <p>I am trying the following:</p>
  
  <pre><code>var dateString =  item["data"] as! String
  let dateFormatter = DateFormatter()
  dateFormatter.dateFormat = "dd-MM-yyyy"
  let date = dateFormatter.date(from: dateString)
  print(date)
  </code></pre>
  
  <p>But my result when printed is null.</p>