可以对compareTime方法进行优化,简化逻辑如下:

public static Boolean compareTime(List stringsTimeList) { if (stringsTimeList.isEmpty()) { return false; }

long nowTime = new Date().getTime();
List<Long> timeList = stringsTimeList.stream()
    .map(DateUtil::timeToDateTime)
    .collect(Collectors.toList());

return !(nowTime < timeList.get(0) || nowTime > timeList.get(1));

}

public static Long timeToDateTimeString time try SimpleDateFormat simpleDateFormat = new SimpleDateFormatYYYY_MM_DD_HH_MM_SS; Date date = simpleDateFormatparsetime;

原文地址: https://www.cveoy.top/t/topic/iqG2 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录