List移除前几个元素
planDetailsEntities.subList(0, 6).clear();
List根据属性 去除重复值
//月份去重
ArrayList<PlanDetailsEntity> detailsEntities = planDetailsEntities.stream()
.collect(Collectors.collectingAndThen(Collectors.toCollection(() ->
new TreeSet<>(Comparator.comparing(PlanDetailsEntity::
getPlandueDate))), ArrayList::new));
计算两个日期计算相差的月份
Temporal temporal1 = LocalDate.parse(this.plandueDate);
Temporal temporal2 = LocalDate.parse(SDF.format(paymentPlansDate));
return Integer.parseInt(String.valueOf(ChronoUnit.MONTHS.between(temporal2,temporal1)));
本文介绍了如何使用Java Stream API去除List中重复元素的方法,并演示了如何清除List的前几个元素。此外,还提供了计算两个日期间相隔月份的实用代码片段。

被折叠的 条评论
为什么被折叠?



