开发者

is NSDateFormatter dateFromString: supposed to return nil for an invalid string?

According to the class reference, dateFromString method returns "A date representation of string interpreted using the receiver’s current settings". Using the following code:

NSDateFormatter * formatter = [[[NSDateFormatter alloc] init] autorelease];
[formatter setLocale:[[[NSLocale alloc] initWithLocaleIdent开发者_开发百科ifier:@"en_US"] autorelease]];
[formatter setDateFormat:@"MMddyy"];
NSDate * date = [formatter dateFromString:@"2010-04-27T17:45:44.763"];

in SDK 3.1.3 returns nil, but on SDK 3.2 it returns 2010-01-20 00:00:00 -0300. Is the 3.2 version the correct behavior?


I think it is supposed to return nil. Use SDK 4.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜