When parsing an input datetime string with the matching format, I am still getting nil back from DateFormatter in swift.
Input string (copied at runtime from variable) and confirmed that is the string running the call with Postman.
"2020-06-30T14:41:33.9"
Parsing method
static func FormatDateTimeString(dateTimeString: String) -> String {
let inputDateFormatter = DateFormatter()
inputDateFormatter.dateFormat = "YYYY-MM-DDThh:mm:ss.s"
let date = inputDateFormatter.date(from:dateTimeString) //date is always nil
let outputDateFormatter = DateFormatter()
outputDateFormatter.dateFormat = "MMM d, yyyy HH:mm"
return outputDateFormatter.string(from: date!)
}
I have also tried "YYYY-MM-DD'T'hh:mm:ss.s"
and "YYYY-MM-DDThh:mm:ss"
but none seem to work.
EDIT: Trying the format suggested below I am still getting nil.
EDIT: As Suggested from the comments I am still getting nil. Format below is: inputDateFormatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.S"
EDIT: Still getting null using the following config