工作中学到的总结
作者:互联网
List 排序
List<LogySbjsJdsbqxxxParts> collectList =
list.stream().sorted(Comparator.comparing(LogySbjsJdsbqxxxParts::getPartsCode) //先根据partsCode字段排序
.thenComparing(LogySbjsJdsbqxxxParts::getSort)).collect(Collectors.toList());//再根据Sort字段排序
解析单元格如果解析日期出现数字的解决方法
//先获取该单元格中的内容str然后转化
Calendar calendar = new GregorianCalendar(1900, 0, -1);
Date d = calendar.getTime();
Date datastr = DateUtils.addDays(d, Integer.valueOf(str));
SimpleDateFormat dataformatter = new SimpleDateFormat( "yyyy-MM-dd");
String str2 = dataformatter.format(datastr);
从List集合中模糊匹配字符串
/*
* 从list集合中模糊匹配字符串
*/
public static boolean search(String name, List<String> list) {
Pattern pattern = Pattern.compile(name);
for (String s : list) {
Matcher matcher = pattern.matcher(s);
if (matcher.find()) {
return true;
}
}
return false;
}
标签:总结,中学,String,List,list,工作,matcher,calendar,排序 来源: https://www.cnblogs.com/hhs-5120/p/16656842.html