java 8 LocalDate 获取某月第一天与最后天
LocalDate date = LocalDate.parse("2019-08-01", DateTimeFormatter.ofPattern("yyyy-MM-dd")); LocalDate first = date.with(TemporalAdjusters.firstDayOfMonth()); LocalDate last = date.with(TemporalAdjusters.lastDayOfMonth()); long days = first.until(last, ChronoUnit.DAYS); System.out.println(days); System.out.println(first.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))); System.out.println(last.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")));
不积跬步无以至千里,不积小流无以成江海