开发者

Problem with iOS Dev: Date Formatting

I have this code:

NSDateFormatter *dateFormatter = [[[NSDateFormatter alloc] init] autorelease];

[dateFormatter setTimeStyle:kCFDateFormatterNoStyle];

[dateFormatter setTimeZone:[NSTimeZone localTimeZone]];

NSString 开发者_JAVA技巧*dateAdded = [dateFormatter stringFromDate:[NSDate date]];

[t appendFormat:@" (added at %@)", dateAdded]; 

t is a NSMutableArray.

I don't know what's wrong with it but the result is dateAdded turned out to be a empty string. If I replace the last line with

[t appendFormat:@" (added at %@)", [NSDate date]];

everything goes just fine, except date is output in raw form.

But what's wrong with my formatting?


Try setting the date style to something other than kCFDateFormatterNoStyle.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜