判断是否今天,今年
public static boolean isToday(long ts) { LocalDateTime today = LocalDateTime.of(LocalDate.now(), LocalTime.of(0, 0, 0)); LocalDateTime tommorrow = today.plusDays(1); long todaySecond = today.atZone(ZoneId.systemDefault()).toEpochSecond(); long tomorrowSeconds = tommorrow.atZone(ZoneId.systemDefault()).toEpochSecond(); return ts >= todaySecond && ts < tomorrowSeconds; } public static boolean isThisYear(long ts) { Instant instant = Instant.ofEpochSecond(ts); LocalDate date = LocalDate.ofInstant(instant, ZoneId.systemDefault()); return date.getYear() == LocalDate.now().getYear(); }