将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: