使用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