/** * @param rptDate 日期 * @return boolean */ public static boolean isAddableDay(Calendar rptDate) { Calendar nowDate = Calendar.getInstance(); Calendar endDate = Calendar.getInstance(); Calendar endDate1 = Calendar.getInstance(); if (endDate.get(Calendar.DAY_OF_MONTH) == 31) { endDate.add(Calendar.DAY_OF_MONTH, -11); endDate1.add(Calendar.DAY_OF_MONTH, -21); } else { endDate.add(Calendar.DAY_OF_MONTH, -9); endDate1.add(Calendar.DAY_OF_MONTH, -18); } // Calendar addableDay=Calendar.getInstance(); // Date date3=DateUtils.getNearestTensDay(endDate); // addableDay.setTime(date3); String date = DateUtil.formatDate(DateUtil.getNearestTensDay(rptDate)); String date1 = DateUtil.formatDate(DateUtil.getNearestTensDay(nowDate)); String date2 = DateUtil.formatDate(DateUtil.getNearestTensDay(endDate)); String date3 = DateUtil.formatDate(DateUtil.getNearestTensDay(endDate1)); return date.equals(date1) || date.equals(date2) || date.equals(date3); // rptDate.before(addableDay); }
/** * @function 获得最近一个周五 * @return 日期 * @throws Exception */ public static Date getLatestFriday() { Calendar cd = Calendar.getInstance(); cd.setTime(DateUtil.parseDate(DateUtil.formatDate(cd.getTime()))); // 获得最近一个周五 int day = cd.get(Calendar.DAY_OF_WEEK); if (day >= 6) { cd.add(Calendar.DATE, -day + 6); } else { cd.add(Calendar.DATE, -day - 1); } return cd.getTime(); }