0

My method is

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

ExcessUIBean class has opendate property

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

I need to sort crExcessMasterList as per opendate property

exexzian
  • 7,782
  • 6
  • 41
  • 52
user2265200
  • 39
  • 3
  • 8
  • `ExcessUIBean` should have a `compareTo` method since it is implementing the `Comparable` interface. Could you post this code if it contains something with `openDate`/`getOpenDate()` involved? – cyroxx May 14 '13 at 12:27
  • This answer may help you: http://stackoverflow.com/a/1814112/1388240 – cyroxx May 14 '13 at 12:39

1 Answers1

1

You need to implement Comparable in the class CrExcessMaster .and then override compareTo()

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

and then use Collections.sort(listName);

PSR
  • 39,804
  • 41
  • 111
  • 151
  • As from the OP's code, it seems that the `Comparable` interface is already implemented, however, we do not know how. If there is already a `compareTo()` method different from your implementation, the OP probably cannot use your solution without breaking things. – cyroxx May 14 '13 at 12:37