public static List<String> lastDays(Integer days, boolean tansFormat) {
LocalDate localDate = LocalDate.now();
LocalDate afterDate = localDate.minusDays((long)days);
List<String> localDateTimes = new ArrayList(days);
for(LocalDate currentdate = afterDate; currentdate.isBefore(localDate) || currentdate.isEqual(localDate); currentdate = currentdate.plusDays(1L)) {
LocalDate localDateTime = LocalDate.of(currentdate.getYear(), currentdate.getMonth(), currentdate.getDayOfMonth());
localDateTimes.add(localDateTime.toString());
}
if (tansFormat) {
return (List)localDateTimes.stream().map((date) -> {
return date.substring(date.indexOf("-") + 1);
}).collect(Collectors.toList());
} else {
return localDateTimes;
}
}
遍历两个日期之间所有日期 工具类(借鉴)
最新推荐文章于 2023-12-26 09:27:54 发布