I am fetching a RSS, in which i receive the following Date stamp:
2010-05-10T06:11:14.000Z
Now i am using NSDateFormatter to parse this datetime stamp.
[parseFormatter setDateFormat:@"yyyy-MM-dTH:m:s.z"];
But its not working fine if just remove the time stamp part it works for the date [parseFormatter setDateFormat:@"yyyy-MM-d"];
But if i add the rest of the stuff it returns nil.
An开发者_开发技巧y idea ?
Thanks in Advance....
You need to parse zero padded values for d, H, m, s
You need to escape the literal T
as 'T'
You need to parse the fractional part of the seconds with SSS
You can accept a literal Z
with 'Z'
or use uppercase Z to try and parse the timezone but RSS uses separate standard.
@"yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"
Date Format Patterns
From memory I've had this problem in the past as well. A couple of things to try:
Replace the "T" in your RSS feed with a space (and obviously change the date format string as well).
Your RSS feed has padded digits, where as your format string does not. Give this a try "yyyy-MM-ddTHH:mm:ss.Z". According to this link, that "z" should be capilized. http://www.stepcase.com/blog/2008/12/02/format-string-for-the-iphone-nsdateformatter/
Strip off the timezone info from the RSS feed and parse this manually. I seem to remember this causing problems for me.
精彩评论