按bean类</crexcessmaster>中的opendate属性列出<crexcessmaster>

时间:2013-05-14 12:23:01

标签: java sorting collections

我的方法是

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

我需要根据crExcessMasterList属性

opendate进行排序

1 个答案:

答案 0 :(得分:1)

您需要在班级Comparable中实施CrExcessMaster。然后覆盖compareTo()

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

然后使用Collections.sort(listName);