我的时间:1386696238
我的代码:
Date date = new Date(Long.parseLong(currentNotification.getDate_created()));
SimpleDateFormat formatter = new SimpleDateFormat("MM/DD/yyyy", Locale.getDefault());
String dateString = formatter.format(date);
我的结果:1/16/1970
期望的结果:12/10/2013
我做错了什么?
最佳答案
您的值以秒为单位,因此您需要将其乘以 1000。
此外,DD
是一年中的某一天,您需要 dd
:
SimpleDateFormat formatter = new SimpleDateFormat("MM/dd/yyyy", Locale.getDefault());
关于Java:纪元日期为 MM/DD/YYYY,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22326468/