最近在做项目时使用到日期格式时发现了一些之前没有注意到的特记录一下
yyyy-MM-dd HH:mm:ss 、yyyy-MM-dd hh:mm:ss
二者区别 HH大写为24小时进制 小写hh为12小时进制
yyyy ==> 年 MM ==> 月 dd ==> 日 HH ==> 24小时制 hh==>12小时进制 mm ==> 分钟 ss ==> 秒
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date date = new Date();
String s = format.format(date);
System.out.println(s);
实例2
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
Date date = new Date();
String s = format.format(date);
System.out.println(s);