将json日期Date转为ios时间
来源:互联网 发布:软件无线电 pdf 编辑:程序博客网 时间:2024/05/01 10:30
/**
* @brief 将Json数据中的Date截取转换成yyyy-MM-dd HH:mm:ss格式的字符串
* @param jsonDatejson数据的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 jsonDatejson数据的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;
}
- 将json日期Date转为ios时间
- 日期处理-将String 转为Date
- date转为json的时间解析
- 将中国标准时间转为日期格式
- ios 将时间戳转为时间类型
- js:将时间obj转为json字符串
- iOS 将json文件转为plist文件
- 字符串日期转为时间
- 将datatable转为json
- 将数据转为json
- 将json 转为DataTable
- 将xml转为json
- 将Date日期类型的字段转换成json字符串
- js 将Date 日期对象转换成时间戳
- JAVA将十位时间戳格式化为日期Date类型
- Scala Date 时间 日期
- 日期时间函数date()
- Date对象之将时间转为毫秒数的方法对比
- JSP编写WAP2.0 XHTML MP 页面
- NHibernate Profiler使用简单教程
- 程序化交易系统大全
- Hibernate 根据实体映射文件自动生成表
- Jquery可编辑table
- 将json日期Date转为ios时间
- c++ operator重载的例子
- SRM 572 div2 1000
- Access restriction: The type xxx is not accessible due to restriction on restriction on required l
- jQuery实现的ajax队列(queue)
- 易语言考试题答案
- Linux用户空间与内核空间
- LINQ常用语句
- spring中context:property-placeholder/元素