Date和LocalDate格式化问题使用的方法不一样,不可以混用
@Testpublic void testDate() {//Date使用SimpleDateFormat做格式化处理SimpleDateFormat df = new SimpleDateFormat("这个日期格式化=yyyyMMdd");Date date = new Date();String string = df.format(date);log.info(string);//LocalDate需要使用DateTimeFormatter来做格式化处理LocalDate now = LocalDate.now();DateTimeFormatter formatter = DateTimeFormatter.ofPattern("这个本地日期格式化=yyyy-MM-dd");String formattedString = now.format(formatter);log.info(formattedString);}
SimpleDateFormat 是格式对象调用日期
DateTimeFormatter 是日期调用格式对象
