List<String> linesList=new ArrayList<>();
linesList.add("2021-05-24 13:59:04 507,106,73,71,57,194,200,179,198,193");
linesList.add("2021-05-24 13:59:04 617,123,55,45,50,212,185,197,174,212");
linesList.add("2021-05-24 13:59:04 728,87,67,65,50,202,194,175,186,184");
linesList.add("2021-05-24 14:00:04 728,87,67,65,50,202,194,175,186,184");
Map<String, List<String>> collectGroup = linesList.stream().collect(Collectors.groupingBy(s -> {
System.out.println("s:"+s);
String[] dataArray = s.split(",");
String time = dataArray[0];
String minuteTime=time.substring(0, 17);
System.out.println("minuteTime:"+minuteTime);
return minuteTime; // 截取分钟时间
}));
System.out.println("=========:");
for(String key:collectGroup.keySet()){
List<String> list=collectGroup.get(key);
System.out.println("key:"+key+" list:"+list);
}
结果: