/**
* @brief 将Json数据中的Date截取转换成yyyy-MM-dd HH:mm:ss格式的字符串
* @param jsonDate json数据的Date
* @return 返回yyyy-MM-dd HH:mm:ss格式的字符串,至于转换成NSDate,自己看着办
*/
+ (NSString *)convertJsonDateToIOSDate:(NSString *)jsonDate
{
//返回的Json日期应该是这样的Date(xxxxxxxxx)
NSString *tmpStr = [jsonDate substringWithRange:NSMakeRange(6, 13)];
//将json日期转变为ios的系统时间
NSTimeInterval userTime = [tmpStr doubleValue];
//设定时间格式,这里可以设置成自己需要的格式
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
//这里比较关键,需要将NSTimeInterval除以1000
NSString *iosDate = [dateFormatter stringFromDate:[NSDate dateWithTimeIntervalSince1970:userTime/1000.0]];
[dateFormatter release];
return iosDate;
}
* @brief 将Json数据中的Date截取转换成yyyy-MM-dd HH:mm:ss格式的字符串
* @param jsonDate json数据的Date
* @return 返回yyyy-MM-dd HH:mm:ss格式的字符串,至于转换成NSDate,自己看着办
*/
+ (NSString *)convertJsonDateToIOSDate:(NSString *)jsonDate
{
//返回的Json日期应该是这样的Date(xxxxxxxxx)
NSString *tmpStr = [jsonDate substringWithRange:NSMakeRange(6, 13)];
//将json日期转变为ios的系统时间
NSTimeInterval userTime = [tmpStr doubleValue];
//设定时间格式,这里可以设置成自己需要的格式
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
//这里比较关键,需要将NSTimeInterval除以1000
NSString *iosDate = [dateFormatter stringFromDate:[NSDate dateWithTimeIntervalSince1970:userTime/1000.0]];
[dateFormatter release];
return iosDate;
}