list集合按照某个元素排序(steam流)-- 实测可行
作者:互联网
// 统计 public class TurnoverCountResultVO { /** * 成交次数 */ private Integer turnoverTimes; /** * 成交运费金额 */ private BigDecimal turnoverFareAmount; /** * 创建时间(按月统计) */ // @JsonFormat(pattern = "yyyy-MM") @JSONField(format = "yyyy-MM-dd") private Date finshedTime; public Integer getTurnoverTimes() { return turnoverTimes; } public void setTurnoverTimes(Integer turnoverTimes) { this.turnoverTimes = turnoverTimes; } public BigDecimal getTurnoverFareAmount() { return turnoverFareAmount; } public void setTurnoverFareAmount(BigDecimal turnoverFareAmount) { this.turnoverFareAmount = turnoverFareAmount; } public Date getFinshedTime() { return finshedTime; } public void setFinshedTime(Date finshedTime) { this.finshedTime = finshedTime; } }
========= 需要对形成的无序集合进行排序 ==========
// 需要根据时间对list集合对象排序
List<TurnoverCountResultVO> collect = newTurnoverTimesList.stream().sorted(Comparator.comparing(TurnoverCountResultVO::getFinshedTime).reversed()).collect(Collectors.toList());
// 反转之后 时间是从小到大
Collections.reverse(collect);
标签:BigDecimal,--,list,turnoverFareAmount,private,public,finshedTime,turnoverTimes,s 来源: https://www.cnblogs.com/zhihongming/p/15845742.html