Ios 在Restkit中将奇怪的日期字符串映射为NSDate
我有一个包含开始和结束日期的Ios 在Restkit中将奇怪的日期字符串映射为NSDate,ios,iphone,objective-c,restkit,nsdateformatter,Ios,Iphone,Objective C,Restkit,Nsdateformatter,我有一个包含开始和结束日期的JSON。但是它们在JSON EndDate: "/Date(1375693200000+0200)/" StartDate: "/Date(1375686000000+0200)/" 我知道您可以将NSDateFormatters添加到RKEntityMapping中,但我不知道如何才能做到这一点?我通常是这样做的 NSDateFormatter *dateFormatter = [NSDateFormatter new]; [dateForma
JSON
。但是它们在JSON
EndDate: "/Date(1375693200000+0200)/"
StartDate: "/Date(1375686000000+0200)/"
我知道您可以将NSDateFormatters
添加到RKEntityMapping
中,但我不知道如何才能做到这一点?我通常是这样做的
NSDateFormatter *dateFormatter = [NSDateFormatter new];
[dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
dateFormatter.timeZone = [NSTimeZone timeZoneWithAbbreviation:@"GMT"];
//dateFormatter.locale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"];
[RKEntityMapping addDefaultDateFormatter:dateFormatter];
有人能帮忙吗?但是json中的字符串不是日期。看起来更像是一个时间间隔。尝试提取值1375693200000并创建具有时间间隔的日期
NSTimeInterval timeInterval = 1375693200000;
NSDate *myDate = [NSDate dateWithTimeIntervalSince1970:timeInterval];
您收到的日期是ASP.NET JSON日期。RestKit具有专门针对以下内容的日期:。学习如何使用它