时间戳格式化
假如你拿到一个时间戳如: 1535077733658 代码如下:
@Test public void testTime()throws Exception{ long time = System.currentTimeMillis(); Date dateTime = new Date(time); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:dd"); String result = simpleDateFormat.format(dateTime); System.out.println(time); //1535077733658 System.out.println(result); //2018-08-24 10:28:24 }