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();
    }

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-05-18
  • 2021-06-04
  • 2021-06-09
猜你喜欢
  • 2021-12-16
  • 2021-08-01
  • 2022-12-23
  • 2021-09-18
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案