I have ordered list of LocalDateTime and I need to split it on midnight of specific date. The order of elements in two new lists should not be changed.
List<LocalDateTime> l = Arrays.asList(LocalDateTime.of(2017,10,24,7,0,0),LocalDateTime.of(2017,10,24,8,0,0),LocalDateTime.of(2017,10,25,7,0,0),LocalDateTime.of(2017,10,25,9,0,0));
Does Collectors.partitioningBy provide a guarantee that the order will be preserved?
l.stream().collect(Collectors.partitioningBy(t-> t.isAfter(LocalDateTime.of(2017,10,25,0,0,0))))
Output:
{false=[2017-10-24T07:00, 2017-10-24T08:00], true=[2017-10-25T07:00, 2017-10-25T09:00]}