Android 填坑之路

Android 时间戳转换 SimpleDateFormat

2018-06-26  本文已影响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

可以了

上一篇 下一篇

猜你喜欢

热点阅读