java时间戳&日期互转

版权声明:你好,欢迎来到我的博客。 https://blog.csdn.net/zwyjg/article/details/72420520

时间戳转日期

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();

猜你喜欢

转载自blog.csdn.net/zwyjg/article/details/72420520