mysql 12小時和24小時轉換


1.12小時顯示 

SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
String time = dateFormat.format(new Date()).toString();
System.out.println(time);

  

 2.24小時顯示

 

SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String time = dateFormat.format(new Date()).toString();
System.out.println(time);

  

 

 

說明:yyyy-MM-dd hh:mm:ss    // 12小時制

          yyyy-MM-dd HH:mm:ss    //24小時制

就是把hh改成大寫的HH.

 

參考: http://www.programgo.com/article/32312471344/#


免責聲明!

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



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