iOS Swift 3 : Convert "yyyy-MM-dd'T'HH:mm:ssZ" format string to date object : <p>Hello i have a dictionary</p>

<pre><code>self.publishedAt = dictionary["publishedAt"] as? NSString
</code></pre>

<p>in which i'm getting date "<strong>2017-01-27T18:36:36Z</strong>". I want to convert it in
readable format : <strong>dd-MM-yyyy hh:mm:ss</strong>. i tried via</p>

<pre><code>let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "dd-MM-yyyy hh:mm:ss"
let date = dateFormatter.date(from: (self.publishedAt as? String)!)
print("EXACT_DATE : \(date)") 
</code></pre>

<p>But getting nil. :(</p>

<p>What is the correct way to get date in simple format?</p>
