Java中将12小时制的时间转换为24小时制的方式如下:

import java.text.SimpleDateFormat;
import java.util.Date;
 
public class ceshi {
    public static void main(String[] args) {
        SimpleDateFormat objSDateFormat = new SimpleDateFormat(
                "yyyy-MM-dd HH:mm:ss");//转换为24小时制
        String strCurrentTime = objSDateFormat.format(new Date());
        System.out.println(strCurrentTime);
    }
 
}

运行结果为:注:大写的HH为24小时制,小写的hh为12小时制,当然还可以在ss的后面加上 a,这样可以在后面显示上下文:显示效果为“2008-03-24 17:00:14 下午”

相关文章:

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