1.判断某一时间 是否在指定时间范围内
// 判断某一时间 是否在指定时间范围内
public static boolean belongCalendar(String nowTime, String beginTime, String endTime) {
DateTimeFormatter dtf = DateTimeFormatter.ofPattern(MyLocalDateTimeUtils.LDT_FORMAT_HHMM);
LocalTime ldtNowTime = LocalTime.parse(nowTime, dtf);
LocalTime ldtBeginTime = LocalTime.parse(beginTime, dtf);
LocalTime ldtEndTime = LocalTime.parse(endTime, dtf);
return ldtNowTime.isAfter(ldtBeginTime) && ldtNowTime.isBefore(ldtEndTime);
}
2.判断某一时间 在指定时间之前
// 判断某一时间 在指定时间之前
public static boolean beforeCalendar(String nowTime, String targetTime) {
DateTimeFormatter dtf = DateTimeFormatter.ofPattern(MyLocalDateTimeUtils.LDT_FORMAT_HHMM);
LocalTime ldtNowTime = LocalTime.parse(nowTime, dtf);
LocalTime ldtTargetTime = LocalTime.parse(targetTime, dtf);
return ldtNowTime.isBefore(ldtTargetTime);
}
3.判断某一时间 在指定时间之后
// 判断某一时间 在指定时间之后
public static boolean afterCalendar(String nowTime, String targetTime) {
DateTimeFormatter dtf = DateTimeFormatter.ofPattern(MyLocalDateTimeUtils.LDT_FORMAT_HHMM);
LocalTime ldtNowTime = LocalTime.parse(nowTime, dtf);
LocalTime ldtTargetTime = LocalTime.parse(targetTime, dtf);
return ldtNowTime.isAfter(ldtTargetTime);
}