I have the following date format:
2016-08-26T05:16:50.200Z
And I am trying to parse similar date formatted strings into Date objects in Swift 3.0.
Here is my effort:
let formatter = DateFormatter()
formatter.dateFormat = "yyyy-mm-dd EEEEE HH:mm:ss Z"
formatter.locale = Locale(identifier: "us")
var date = formatter.date(from: date_str)!
Where date_str is of the format mentioned above.
Unfortunately, swift don't recognize the format and returns nil.
Note: I don't want to change the string to match the formatter, but to adapt the formatter to the format of the string. String is of external source so I don't have the ability to change the string's format, but to stick with it and create a formatter that will recognize the string's date pattern.
Any ideas on where my format is wrong?
