美文网首页Android 填坑之路
Android 时间戳转换 SimpleDateFormat

Android 时间戳转换 SimpleDateFormat

作者: 雪纳瑞的哈士奇 | 来源:发表于2018-06-26 11:29 被阅读406次

Stringres;

SimpleDateFormat simpleDateFormat =new SimpleDateFormat(pattern);

long lt =new Long(milSecond);

Date date =new Date(lt);

res = simpleDateFormat.format(date);

return res;

很奇怪  转换出来是1970年

Stringres;

SimpleDateFormat simpleDateFormat =new SimpleDateFormat(pattern);

long lt =new Long(milSecond);

Date date =new Date(lt *1000L);

res = simpleDateFormat.format(date);

return res;

就加了个*1000L

可以了

相关文章

网友评论

    本文标题:Android 时间戳转换 SimpleDateFormat

    本文链接:https://www.haomeiwen.com/subject/fevpyftx.html