0
我得到JSON解析日期,我想使用NSDateFormatter,但沒有成功。關於JSON日期轉換錯誤
1.JSON獲取控制檯登錄
IncidentReceiveTime = "/Date(1353914100000+0800)/";
2.my代碼
NSString *dateStr =[NSString stringWithFormat:@"%@",[[[DateSortArry objectAtIndex:0] objectForKey:@"IncidentReceiveTime"]stringByReplacingOccurrencesOfString:@"/" withString:@""]];
NSLog(@"dateStr:%@",dateStr);
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc]init];
[dateFormatter setLocale:[NSLocale currentLocale]];
[dateFormatter setDateFormat:@"yyyy-MM-ddHH"];
NSDate *date = [dateFormatter dateFromString:dateStr];
NSLog(@"date:%@",date);
3.NSDateFormatter控制檯日誌
dateStr:Date(1361943694000+0800)
date:(null)
嘗試'NSDateFormatter'對象的'setDateStyle:'屬性。 – Malloc
[解析iPhone上的JSON日期](http://stackoverflow.com/questions/1757303/parsing-json-dates-on-iphone) – rmaddy