Java:epoch日期为MM/DD/YYYY

CQM*_*CQM 3 java date epoch simpledateformat

我的时间:1386696238

我的代码:

Date date = new Date(Long.parseLong(currentNotification.getDate_created()));
        SimpleDateFormat formatter = new SimpleDateFormat("MM/DD/yyyy", Locale.getDefault());
        String dateString = formatter.format(date);
Run Code Online (Sandbox Code Playgroud)

我的结果: 1/16/1970

期望的结果: 12/10/2013

我究竟做错了什么?

Kep*_*pil 6

您的值以秒为单位,因此您需要将其乘以1000.

此外,DD是一年中的一天,你想要dd:

SimpleDateFormat formatter = new SimpleDateFormat("MM/dd/yyyy", Locale.getDefault());
Run Code Online (Sandbox Code Playgroud)