zoukankan      html  css  js  c++  java
  • Collections使用

    private void listSortByDate(List<CTagSet> listSort,int sortType, String sortRow)
    {
        Collections.sort(list,new CTagSetComparator(sortType,sortRow));
    }
    static class CTagSetComparator implement Comparator<CTagSet>, Serializable
    {
        int sortType;
        String sortRow;
        int flag = -1;
        public CTagSetComparator(int sortType, String sortRow){
            this.sortType = sortType;
            this.sortRow = sortRow;
        }
        public int compare(CTagSet s1, CTagSet s2)
        {
            if(null == sortRow || sortRow.isEmpty())
            {
                sortRow = "RECDATE"
            }
            String recDateStr1 = s1.GetValue(sortRow);
            String recDateStr2 = s2.GetValue(sortRow);
            if(null != recDateStr1 && null != recDateStr2)
            {
                try
                {
                    Date recDateStr1 = Dates.parseDateTime(recDateStr1);
                    Date recDateStr2 = Dates.parseDateTime(recDateStr2);
                    flag = recDateStr1.compareTo(recDate2);
                }catch(Exception e)
                {
                    return flag;
                }
            }else{
                return flag;
            }
            return flag*sortType;
        }
    }

  • 相关阅读:
    Maya 与 Matlab 数据互联插件使用教程
    代码可视化算法流程
    sql 至少含有
    sql update limit1
    c# windows service 程序
    c#和.net区别
    c#数据库乱码
    c#事件实质
    c#非界面线程控制控件
    mysql唯一查询
  • 原文地址:https://www.cnblogs.com/happyrocky/p/Collections.html
Copyright © 2011-2022 走看看