Rup*_*ert 1 iphone xcode cocoa-touch objective-c
嗨我试图将NSString转换为NSDate
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss ZZZZ"];
NSDate *dateFromString = [[NSDate alloc] init];
dateFromString = [dateFormatter dateFromString:lastModified];
Run Code Online (Sandbox Code Playgroud)
但是当我做的时候
NSLog(@" date: %@ ", dateFromString);
Run Code Online (Sandbox Code Playgroud)
我得到约会:( null)
lastModified字符串的日期格式为"Tue,2011年2月15日13:30:42 GMT"
我究竟做错了什么?
您的input(lastModified
)与指定的日期格式不匹配.
正确形成lastModified
的日期格式指定时间的字符串表示形式为:
"2011-02-15 13:30:42 GMT"
,但你过去了"Tue, 15 Feb 2011 13:30:42 GMT"
.
归档时间: |
|
查看次数: |
1517 次 |
最近记录: |