使用FastDateFormat替换SimpleDateFormat
以前对日期格式化的写法:
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String format = simpleDateFormat.format(new Date());
System.out.println(format);
使用FastDateFormat进行优化的写法:
默认已经导入了hutool工具包
System.out.println(DatePattern.NORM_DATETIME_FORMAT.format(new Date()));
返回结果:
2021-03-25 10:16:47