gpt4 book ai didi

java - 按 bean 类中的 opendate 属性对 List 进行排序

转载 作者:行者123 更新时间:2023-12-01 14:35:22 24 4
gpt4 key购买 nike

我的方法是

public FilteredUIExcessList getCustomerExcesses(Long cif,String primaryCO) throws Exception {
if (cif != null && !cif.equals(0L)) {
List<CrExcessMaster> crExcessMasterList = getExcessDbService()
.getExcessesForCustomer(cif);
}

ExcessUIBean 类具有 opendate 属性

public class ExcessUIBean implements Comparable<ExcessUIBean>{

private boolean notifyDaHolder;
private String daValueForUser;
private String excessId;
private String excessDa;
private String status;
private String product;
private String measure;
private String currency;
private String limitAtExcess;
private String excessAmount;
private String excessDate;
private String maxRiskAmount;
private String maxRiskDate;
private String comments;
private String preDefinedComments;
private String openDate;

public String getOpenDate() {
return openDate;
}

public void setOpenDate(String openDate) {
this.openDate = openDate;
}
//getters and setters

我需要根据 opendate 属性对 crExcessMasterList 进行排序

最佳答案

您需要在类 CrExcessMaster 中实现 Comparable ,然后重写 compareTo()

         public int compareTo(CrExcessMaster obj) {
return openDate.compareTo(obj.getOpenDate)
}

然后使用Collections.sort(listName);

关于java - 按 bean 类中的 opendate 属性对 List<CrExcessMaster> 进行排序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16543041/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com