java时间戳&日期互转

来源:互联网 发布:java if 大小写 编辑:程序博客网 时间:2024/06/06 00:53

时间戳转日期

SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");Date date = new Date(Long.parseLong(1495010809865+""));String res = simpleDateFormat.format(date);

日期转时间戳

SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");Date date = simpleDateFormat.parse("2017-05-17 16:46:49");long ts = date.getTime();


原创粉丝点击