2013-05-14 24 views
0

我的方法是排序列表<CrExcessMaster>由bean類Opendate裏的財產

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作爲

+0

'ExcessUIBean'應該有一個'compareTo'方法,因爲它正在執行'Comparable'接口。你可以發佈這個代碼,如果它包含'openDate' /'getOpenDate()'涉及的東西? – cyroxx 2013-05-14 12:27:12

+0

這個答案可能會幫助你:http://stackoverflow.com/a/1814112/1388240 – cyroxx 2013-05-14 12:39:01

回答

1

您挑選需要在類CrExcessMaster中執行Comparable。然後覆蓋compareTo()

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

,然後使用Collections.sort(listName);

+0

從OP的代碼看來,似乎'Comparable'接口已經實現,但是,我們不知道如何。如果已經有一個與你的實現不同的'compareTo()'方法,OP可能不會在不破壞事物的情況下使用你的解決方案。 – cyroxx 2013-05-14 12:37:31