使用SimpleDateFormat 將毫秒轉換成時分秒 格式:HH:mm:ss


 

public static String dateFormatFromMilliSecond(long seconds) {   

 

    //初始化format格式

   SimpleDateFormat dateFormat= new SimpleDateFormat("HH:mm:ss");      

 

  //設置時區,跳過此步驟會默認設置為"GMT+08:00" 得到的結果會多出來8個小時

   dateFormat.setTimeZone(TimeZone.getTimeZone("GMT+00:00"));

 

   String time= dateFormat.format(seconds);

 

 return time;

}


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM