更新 iPad 8.3 版后的日期格式问题下面的代码返回 NIL 值,但在模拟器和 iPod 中工作正常
-(NSString *)dateFormatNSString *)str{
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat"yyyy/mm/dd HH:mm:ss zzz"];
NSDate *dateFromString = [[NSDate alloc] init];
dateFromString = [dateFormatter dateFromString:str];
//problem here when i call this method from simulator and ipod it runs perfectly
//and returns 2015-01-27 00:27:48 +0000 but in case of IPad(iOS 8.3) it return NIL
NSDateFormatter* df = [[NSDateFormatter alloc] init];
[df setDateStyle:NSDateFormatterMediumStyle];
[df setTimeStyle:NSDateFormatterShortStyle];
NSString* myString = [df stringFromDate:dateFromString];
return myString;
}
//code to call above method with date string which are return from web service
[self dateFormat"2015/01/26 16:27:48 PST"];
Best Answer-推荐答案 strong>
检查输入字符串日期格式。 应该是这样的格式: - yyyy/MM/dd HH:mm:ss zzz
关于ios - 更新 iPad 8.3 版后的日期格式问题,我们在Stack Overflow上找到一个类似的问题:
https://stackoverflow.com/questions/30252155/
|