【发布时间】:2014-04-15 02:36:35
【问题描述】:
我的时间: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
我做错了什么?
【问题讨论】:
-
月日:
d(小写) -
@Reimeus 乘以 1000 在我的申请中给出了正确的日期
-
java.util日期时间 API 及其格式化 APISimpleDateFormat已过时且容易出错。建议完全停止使用它们并切换到modern Date-Time API。使用现代日期时间 API 检查this page 以获得答案。
标签: java date simpledateformat epoch