java 将两个List对象合并并去重
作者:互联网
import java.time.format.DateTimeFormatter;
import java.util.Collection;
import java.util.stream.Collectors;
import java.util.stream.Stream;
List<OrderAppointmentSales> orderAppointmentSales = obcOrderAppointmentSalesService.getOrderAppointmentSalesList(syncTime);
List<OrderAppointmentSales> orderAppointmentSales2 = obcOrderAppointmentSalesService.getOrderAppointmentSalesListByTime(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSSSSS").format(sas.getUpdateTime()));
//将数据list对象合并去重 使用Stream来帮我们完成操作
List<OrderAppointmentSales> ords = Stream.of(orderAppointmentSales, orderAppointmentSales2)
.flatMap(Collection::stream)
.distinct()
.collect(Collectors.toList());
标签:java,Stream,stream,合并,List,util,import 来源: https://www.cnblogs.com/darling331/p/16550570.html