我有一个 LocalDateTime 列表,需要在特定日期的午夜将其拆分。两个新列表中元素的顺序不应更改。
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));
Collectors.partitioningBy能保证顺序不变吗?
l.stream().collect(Collectors.partitioningBy(t-> t.isAfter(LocalDateTime.of(2017,10,25,0,0,0))))
输出:
{false=[2017-10-24T07:00, 2017-10-24T08:00], true=[2017-10-25T07:00, 2017-10-25T09:00]}
Collectors.partitioningBy
ж›өжњ‰ж•€зҺ‡гЂ‚еҢ“дҢ ж‰ң到拆分ж—Өжњџзљ„зөұеә•еђҺпәЊдңүеЏҮе€›е»ғеҺџе§‹е€—иҰЁзљ„дё¤дёҒеђе€—иҰЁгЂ‚ - Eran