接口返回的数据:
<time>1377000845058</time>
解析:
//时间戳转时间,时间的格式设置
NSDateFormatter* formatter = [[[NSDateFormatteralloc] init]autorelease];
[formatter setDateStyle:NSDateFormatterMediumStyle];
[formatter setTimeStyle:NSDateFormatterShortStyle];
[formatter setDateFormat:@"YYYY-MM-dd HH:mm:ss"];
NSDate *confromTimesp = [NSDatedateWithTimeIntervalSince1970:[bean.timedoubleValue]/1000];
NSLog(@"changTime = %@",confromTimesp);
//将NSDate类型转化为string类型,方便label赋值
Nsstring *timeString=[formatter stringFromDate:confromTimesp];
time_label.text=timeString;//这样time_label显示将会按照YYYY-MM-dd HH:mm:ss这种样式显示时间
原文地址:https://www.jb51.cc/xml/299733.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。