I have a stream that outputs a set:
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);
}
I also have a method that checks the difference between dates. Between the first and the second.
// Displays the difference. In this case, one month.
GFG.findDifference("2020-09-12", "2020-10-12");
Is it possible to add this method of calculating the date difference to the stream? To immediately calculate for all dates.
I need to get this output
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