Having a problem with NSDateFormatter.
So I have a date string formatted "yyyy-MM-dd"
, for example 2015-09-22.
However when I pass this into NSDateFormatter.dateFromString, the method returns nil. My code is as follows:
let dateFormatter = NSDateFormatter()
dateFormatter.dateFormat = "yyyy-MM-dd"
dateFormatter.locale = NSLocale(localeIdentifier: "en_US_POSIX")
let dateAsNSDate = dateFormatter.dateFromString(payload.objectForKey("messageExpiry") as! String)
From the debugger console at a breakpoint just above this code:
po payload.objectForKey("messageExpiry") as! String
"2015-09-31"
I have explored other questions similar to this but am as of yet still unable to fix this problem. Any and all help would be appreciated.