0
我试图将时间戳转换为人类可读的日期和时间。我想:将unix/epoch时间转换为格式化日期 - 意外日期
String dateSt = 1386580621268;
Log.i("*****", "date st is = "+dateSt);
long unixSeconds = Long.parseLong(dateSt);
Log.i("*******", "unix seconds is = "+unixSeconds);
Date date = new Date(unixSeconds*1000L); // *1000 is to convert seconds to milliseconds
SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy"); // the format of your date
String formattedDate = sdf.format(date);
System.out.println(formattedDate);
预期的结果是要09-12-2013
,但是我得到28-12-45908
。上面的例子可以发现于:Convert Unix timestamp to date java, answer by David Hofmann
啊我看到了,非常感谢你清除那个。它现在正常工作:)我刚刚删除了像你所建议的'* 1000L'。再次感谢。 – DevC