NSDateFormatter Twitter JSON Api
我正在尝试将 NSDate 格式化为 Twitter api (JSON) 给出的日期。因此我使用 NSDateFormatter 。
NSString *dateString = string;
NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
//[dateFormat setDateFormat: @"EEE dd MMM yyyy HH:mm:ss Z"];
NSDate *date = [dateFormat dateFromString:dateString];
NSLog(@"%@",date);
return date;
但是,这会返回 null。 Twitter API 给我的日期如下所示:2012 年 1 月 19 日星期四 07:04:51 +0000。
有人有解决这个问题的办法吗?
谢谢!
I'm trying to format an NSDate out of a date given by the Twitter api (JSON). I'm using a NSDateFormatter therefore.
NSString *dateString = string;
NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
//[dateFormat setDateFormat: @"EEE dd MMM yyyy HH:mm:ss Z"];
NSDate *date = [dateFormat dateFromString:dateString];
NSLog(@"%@",date);
return date;
But, this returns null. The date the Twitter API is giving me is looking like this: Thu, 19 Jan 2012 07:04:51 +0000.
Does anyone have a solution for this problem?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您错过了格式字符串中日期后面的逗号。正确:
You missed the comma following the day in your format string. Correctly: