开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜