gpt4 book ai didi

objective-c - IOS 6 和 NSDateFormatter

转载 作者:可可西里 更新时间:2023-11-01 04:53:52 27 4
gpt4 key购买 nike

代码如下:

NSString * str = @"2012-11-23Fri09:00:00+0100";

NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
NSLocale *locale= [[NSLocale alloc] initWithLocaleIdentifier:@"en_US"];
[formatter setLocale:locale];

[formatter setDateFormat:@"yyyy-MM-ddEEEHH:mm:ssZ"];

NSDate *result = [formatter dateFromString:str];
NSLog(@"str :%@ -- NSDate :%@", str, result);

这是输出:

str :2012-11-23Fri09:00:00+0100 -- NSDate :1999-12-31 08:00:00 +0000

为什么 NSDate 是错误的?

最佳答案

查看此链接可能对您有帮助,

Formatters in OS X v10.8 and iOS 6.0

Formatters in iOS 5.0-5.1

谢谢,

山南

关于objective-c - IOS 6 和 NSDateFormatter,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13583481/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com