使用java代码将时间戳和时间互相转换


时间戳转时间:

SimpleDateFormat simpleDateFormat = null;

simpleDateFormat = new SimpleDateFormat("yyyyMMdd");
Date date = new Date(System.currentTimeMillis()); String day = simpleDateFormat.format(date);
simpleDateFormat = new SimpleDateFormat("HHmmss");  
String time
= simpleDateFormat1.format(date);

时间转时间戳

SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date date = simpleDateFormat.parse(s);
long ts = date.getTime();

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM