1 /** 2 * 判断现在时间时间在两个时间段之间 3 * 4 * @param nowTime1 现在时间 5 * @param startTime1 开始时间 6 * @param endTime1 结束时间 7 * @return 8 * @throws ParseException 9 */ 10 public static boolean isEffectiveDate(String nowTime1, String startTime1, String endTime1) throws ParseException { 11 String format = "HH:mm:ss"; 12 Date nowTime = new SimpleDateFormat(format).parse(nowTime1); 13 Date startTime = new SimpleDateFormat(format).parse(startTime1); 14 Date endTime = new SimpleDateFormat(format).parse(endTime1); 15 Calendar date = Calendar.getInstance(); 16 date.setTime(nowTime); 17 Calendar begin = Calendar.getInstance(); 18 begin.setTime(startTime); 19 Calendar end = Calendar.getInstance(); 20 end.setTime(endTime); 21 if (date.after(begin) && date.before(end)) { 22 return true; 23 } else { 24 return false; 25 } 26 }
原文地址:https://www.cnblogs.com/mzc--/p/12161823.html
时间: 2024-11-07 05:29:08