我有一个输出集合的流:
1=[15.01.2021,30.09.2012]
2=[12.05.2021,02.01.2021]
3=[14.02.2021]
4=[11.05.2022]
private static void groupDateById (Collection <Logs> firstFileLog,Collection <Logs> second) {
Stream.of (firstFileLog,second)
.flatMap (Collection::stream)
.collect(Collectors.groupingBy(Logs::getId,Collectors.mapping(Logs::getTime,Collectors.toList())))
.entryset().forEach(System.out::println);
}
我还有一个方法可以检查日期之间的差异。在第一个和第二个之间。
// Displays the difference. In this case,one month.
GFG.findDifference("2020-09-12","2020-10-12");
是否可以将这种计算日期差异的方法添加到流中?立即计算所有日期。
我需要得到这个输出
1=[15.01.2021,30.09.2012],difference(second date - first) 99 month
2=[12.05.2021,02.01.2021],difference(second date - first)..
3=[14.02.2021] - ignore
4=[11.05.2022] - ignore