SimpleDateFormat时间显示24小时和12小时时间格式

 1     public static void main(String[] args) {
 2         Date date = new Date();
 3         System.out.println("date = " + date);//date = Sat Aug 29 17:06:01 CST 2020
 4         SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
 5         SimpleDateFormat simpleDateFormat1 = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
 6         String format = simpleDateFormat.format(date);
 7         System.out.println("format = " + format);//format = 2020-08-29 17:06:01
 8         String format1 = simpleDateFormat1.format(date);
 9         System.out.println("format1 = " + format1);//format1 = 2020-08-29 05:06:01
10     }

 

posted @ 2020-08-29 17:09  SimonShixinlong  阅读(735)  评论(0)    收藏  举报