I am converting a string returned from server to NSDate object for further use.
Here is the sample string from server:
Code:
2011-01-14T16:05:48.555+05:00
And, I use
Code:
[dateFormatter setDateFormat:@"yyyy-MM-dd'T'HH:mm:ss"];
I am able to successfully convert it to an NSDate object using dataFromString method on iOS 3.2 (device & sim both).
However, the same code returns nil on iOS 4.2 on device & sim both.
I have also tried many variations of date format patterns such as:
Code:
[dateFormatter setDateFormat:@"yyyy-MM-dd'T'HH:mm:ss.SSSZ"];
[dateFormatter setDateFormat:@"yyyy-MM-dd'T'HH:mm:ss.SSSZZZZ"];
[dateFormatter setDateFormat:@"YYY-MM-DD'T'HH:mm:ss.fffK"];
but nothing works!!
Am I missing something here?
EDIT: I tried to hard-code the input string and after trying many variations, the following string
Code:
2011-01-14T16:05:48.555+0500
worked with
Code:
"yyyy-MM-dd'T'HH:mm:ss.SSSZ"
Notice that the only difference in this string and the one from server is; the colon (:) in TimeZone value. I tried to find a date pattern where I can mention the colon in timezone with no success.
Any clue??