NSDateFormatter not working... where am i wrong?
i'm trying to parse a date writte in UTC format. For example
NSString *o = @"2011-04-23$20:28:00Z";
Here's the code i'm using:
df = [[NSDateFormatte开发者_开发知识库r alloc] init];
[df setDateFormat:@"yyyy-MM-dd$HH:mm:00Z"];
NSLog(@"^%@^ => %@", o, [df stringFromDate:[df dateFromString:o]]);
it produces the logging
^2011-04-23$20:28:00Z^ => (null)
Where am i wrong?
Thanks!
The Z
symbol in a date format string specifies a field for the timezone, if you want to parse the literal "Z", you will need to escape it with a '
: yyyy-MM-dd$HH:mm:00'Z
.
精彩评论