获取今天
String today = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
获取明天
String tomorrowStr = LocalDate.now().plusDays(1).atStartOfDay().atZone(ZoneId.systemDefault()).format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
获取当月最后一天
String lastDay = LocalDate.now().with(TemporalAdjusters.lastDayOfMonth()).format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
可以看到JDK8获取时间要比之前的版本要简洁很多
其中atStartOfDay是吧时分秒给清零,如果使用时间类型,最好清除掉,如果只是获取字符串类型的,可以省略.但是严谨一点最好还是加上.