public static Long timeToDateTimeString time try SimpleDateFormat simpleDateFormat = new SimpleDateFormatYYYY_MM_DD_HH_MM_SS; Date date = simpleDateFormatparsetime;
可以对compareTime方法进行优化,简化逻辑如下:
public static Boolean compareTime(List
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));
}
原文地址: https://www.cveoy.top/t/topic/iqG2 著作权归作者所有。请勿转载和采集!