将linux时间戳转换为android日期 [英] Convert linux timestamp to android date

查看:139
本文介绍了将linux时间戳转换为android日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须将linux时间戳转换为android日期。
i从服务器获取此号码

I must convert a linux timestamp to android date. i get this number from server

1386889262

我写了一个小代码片段。

I have written a small code snippet.

Date d = new Date(jsonProductData.getLong(MTIME));
SimpleDateFormat f = new SimpleDateFormat("dd.MM.yyyy");
.setTimeZone(TimeZone.getTimeZone("GMT"));
formatTime = f.format(d);

但它没有转换,这是我的结果

but it doesen't convert right, this is my result

17.01.1970

编辑
通常我必须在这里得到这个

EDIT: Normally i must get this here

12.12.2013

是否有另一种方法可以获得正确的约会对象???

Is there an another method to get the right date???

推荐答案

UNIX时间戳应以毫秒为单位,因此将Long值乘以1000.因此您的值1386889262将为1386889262000:

UNIX timestamp should be in milliseconds so multiply the Long value by 1000. So your value 1386889262 would be 1386889262000:

这篇关于将linux时间戳转换为android日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆