时间天数差
private int diffInDays(Date star, Date endDay) { Date nextDay = star; int diffInDays = 1; while(nextDay.before(endDay)){//当明天不在结束时间之前是终止循环 Calendar cld = Calendar.getInstance(); cld.setTime(star); cld.add(Calendar.DATE, 1); star = cld.getTime(); //获得下一天日期字符串 nextDay = star; System.out.println("-----------"+nextDay); diffInDays++; } return diffInDays; }
list 中根据字符串 查询对象
List<SigninRecord>
private SigninRecord search(Date signinTime, List<SigninRecord> list){ SigninRecord results = new SigninRecord(); DateFormat dateFormat = new SimpleDateFormat("yyy-MM-dd"); Pattern pattern = Pattern.compile(dateFormat.format(signinTime)); //不区分大小写 // Pattern pattern = Pattern.compile(name,Pattern.CASE_INSENSITIVE); for(int i=0; i < list.size(); i++){ Matcher matcher = pattern.matcher(list.get(i).getSigninTime().toString()); if(matcher.find()){ results = list.get(i); } } return results; }
标签:java,cld,天数,list,时间,Pattern,Date,star,diffInDays From: https://www.cnblogs.com/pxuan/p/17595997.html