Why does my NSDateFormatter sometimes return an a.m. or p.m. with yyyyMMddHHmmssSSS

来源:互联网 发布:淘宝卖家能知道买家 编辑:程序博客网 时间:2024/06/04 23:36


需要设置Locale

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

 [dateFormattersetDateFormat:@"yyyyMMddHHmmss"];

 NSDate *currentDate = [[[NSDatealloc] init]autorelease];

 [dateFormatter setCalendar:[NSCalendarautoupdatingCurrentCalendar]];

[dateFormatter setLocale:[[[NSLocalealloc] initWithLocaleIdentifier:@"en_US"]autorelease]];

NSString *strDate = [dateFormatterstringFromDate:currentDate];



http://stackoverflow.com/questions/7072267/why-does-my-nsdateformatter-sometimes-return-an-a-m-or-p-m-with-yyyymmddhhmmss

0 0
原创粉丝点击