工作总结(一)
2012-07-18 17:49
183 查看
1、List是否为空
如果返回null或empty,返回true。
2、Key为key的map在map中是否存在
3、System.currentTimeMillis();
从1970年1月1日到现在的毫秒数,常用于游戏时间的相关设定,跟线程执行有很大的相关性。
4、Java中Comparator的用法
①实体类Step
List<Integer> list = new Array<Integer>(); if (CollectionUtils.isEmpty(userOtfList)) { break; }
如果返回null或empty,返回true。
2、Key为key的map在map中是否存在
Map<String,List<Integer>> map= new HashMap<String,List<Integer>>(); if(!map.containsKey(String.valueOf(key))){ map.put(String.valueOf(outfitId), new ArrayList<Integer>()); }
3、System.currentTimeMillis();
从1970年1月1日到现在的毫秒数,常用于游戏时间的相关设定,跟线程执行有很大的相关性。
4、Java中Comparator的用法
①实体类Step
package com.ljq.entity; /** * 运号单流程 * * @author Administrator * */ public class Step{ /** 处理时间 */ private String acceptTime = ""; /** 快件所在地点 */ private String acceptAddress = ""; public Step() { super(); } public Step(String acceptTime, String acceptAddress) { super(); this.acceptTime = acceptTime; this.acceptAddress = acceptAddress; } public String getAcceptTime() { return acceptTime; } public void setAcceptTime(String acceptTime) { this.acceptTime = acceptTime; } public String getAcceptAddress() { return acceptAddress; } public void setAcceptAddress(String acceptAddress) { this.acceptAddress = acceptAddress; } }②实现Comparator接口
package com.ljq.entity; import java.util.Comparator; import java.util.Date; import com.ljq.util.UtilTool; /** * 对Step类进行排序 * * @author Administrator * */ public class StepComparator implements Comparator<Step>{ /** * 如果o1小于o2,返回一个负数;如果o1大于o2,返回一个正数;如果他们相等,则返回0; */ @Override public int compare(Step o1, Step o2) { Date acceptTime1=UtilTool.strToDate(o1.getAcceptTime(), null); Date acceptTime2=UtilTool.strToDate(o2.getAcceptTime(), null); //对日期字段进行升序,如果欲降序可采用before方法 if(acceptTime1.after(acceptTime2)) return 1; return -1; } }③测试
package junit; import java.util.Collection; import java.util.Collections; import java.util.List; import org.junit.Test; public class StepComparatorTest { @Test public void sort() throws Exception{ List<Step> steps=new ArrayList<Step>; //对集合对象进行排序 StepComparator comparator=new StepComparator(); Collections.sort(steps, comparator); if(steps!=null&&steps.size()>0){ for(Step step:steps){ System.out.println(step.getAcceptAddress()); System.out.println(step.getAcceptTime()); } } } }
相关文章推荐
- 正式入职1个半月的工作总结
- 通过机房工作看软工之软工总结
- Liunx命令工作总结(2)
- [工作问题总结]C# 实现取得全局资源文件
- 2014-3-31~2014-4-6工作总结
- 开发ActiveX,一些工作总结
- 10月工作总结
- 2011年--那个季节的工作总结
- 今日工作总结
- [工作问题总结]C# iframe 跨域测试是否链接
- 第二周工作总结
- 2015年年度工作总结
- 第二阶段团队冲刺个人工作总结六
- 工作一年多了,突然想总结下
- 2015年3月11日工作总结
- iOS 工作之余小总结(五)--(1) Block在程序中的三个用法
- 2015年工作与学习总结(2015-07-10 22:44、2015-12-01 11:39、2016-1-18 22:44)
- 第二周工作总结
- 最近工作的一点总结
- 2010-2011工作总结