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/#

相关文章:

  • 2022-12-23
  • 2022-02-21
  • 2021-12-16
  • 2021-10-09
  • 2022-12-23
  • 2021-08-15
  • 2022-12-23
猜你喜欢
  • 2021-09-14
  • 2021-07-10
  • 2022-12-23
  • 2021-10-22
  • 2022-02-01
  • 2022-12-23
  • 2021-10-11
相关资源
相似解决方案