| | |
| | | import java.math.RoundingMode; |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.Instant; |
| | | import java.time.LocalDate; |
| | | import java.time.ZoneId; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | |
| | | .filter(record -> { |
| | | try { |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm"); |
| | | String substring = record.getTimeFrame().substring(11); |
| | | String substring = record.getTimeFrame().substring(0,16); |
| | | Date time = sdf.parse(substring); |
| | | return !time.before(lastWeekStartDate) && !time.after(lastOfDate); |
| | | Instant instant = time.toInstant(); |
| | | LocalDate dateToCheck = instant.atZone(ZoneId.systemDefault()).toLocalDate(); |
| | | // 获取今天的日期 |
| | | LocalDate today = LocalDate.now(); |
| | | // 计算一周前的日期 |
| | | LocalDate oneWeekAgo = today.minusWeeks(1); |
| | | // 计算一周后的日期 |
| | | LocalDate oneWeekLater = today.plusWeeks(1); |
| | | return dateToCheck.isAfter(oneWeekAgo) && dateToCheck.isBefore(oneWeekLater); |
| | | } catch (ParseException e) { |
| | | e.printStackTrace(); |
| | | return false; |
| | |
| | | recordAppoints = recordAppoints.stream() |
| | | .filter(record -> { |
| | | try { |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); |
| | | Date time = sdf.parse(record.getTimeFrame().substring(11)); |
| | | return !time.before(lastMonthStartDate) && !time.after(lastOfDate); |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm"); |
| | | String substring = record.getTimeFrame().substring(0,16); |
| | | Date time = sdf.parse(substring); |
| | | Instant instant = time.toInstant(); |
| | | LocalDate dateToCheck = instant.atZone(ZoneId.systemDefault()).toLocalDate(); |
| | | // 获取今天的日期 |
| | | LocalDate today = LocalDate.now(); |
| | | // 计算一周前的日期 |
| | | LocalDate oneWeekAgo = today.minusMonths(1); |
| | | // 计算一周后的日期 |
| | | LocalDate oneWeekLater = today.plusMonths(1); |
| | | return dateToCheck.isAfter(oneWeekAgo) && dateToCheck.isBefore(oneWeekLater); |
| | | } catch (ParseException e) { |
| | | e.printStackTrace(); |
| | | return false; |
| | |
| | | .filter(record -> { |
| | | try { |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm"); |
| | | Date time = sdf.parse(record.getTimeFrame().substring(11)); |
| | | return !time.before(lastYearStartDate) && !time.after(lastOfDate); |
| | | String substring = record.getTimeFrame().substring(0,16); |
| | | Date time = sdf.parse(substring); |
| | | Instant instant = time.toInstant(); |
| | | LocalDate dateToCheck = instant.atZone(ZoneId.systemDefault()).toLocalDate(); |
| | | // 获取今天的日期 |
| | | LocalDate today = LocalDate.now(); |
| | | // 计算一周前的日期 |
| | | LocalDate oneWeekAgo = today.minusYears(1); |
| | | // 计算一周后的日期 |
| | | LocalDate oneWeekLater = today.plusYears(1); |
| | | return dateToCheck.isAfter(oneWeekAgo) && dateToCheck.isBefore(oneWeekLater); |
| | | } catch (ParseException e) { |
| | | e.printStackTrace(); |
| | | return false; |