时间类型在开发中经常使用,这面是实际需求中的常用方法
//日期格式化对象
DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
//获取系统的LocalDateTime格式的当前时间
LocalDateTime dateTime = LocalDateTime.now();
//这一步将时间转成String
String time = df.format(dateTime);
//这一步截取年月日
String substring = time.substring(0, 10);
boolean b = substring.equals("2021-07-16");
//时间计算 计算7天后的时间
LocalDateTime dateTime1 = dateTime.plusDays(7);
//String 类型的时间转成 LocalDateTime
LocalDateTime.parse("2021-07-12 17:07:05",df);
开发中使用到做此笔记