开区间,表示不包括节点时间,不多说,上代码:
/** * 判断time是否在from,to之内 开区间 * * @author xj * @date 2017/11/23 16:56 * @param time 时间 * @param from, 开始时间 * @param to 结束时间 * @return boolean */ public static boolean belongCalendar(Date time, Date from, Date to) { Calendar date = Calendar.getInstance(); date.setTime(time); Calendar after = Calendar.getInstance(); after.setTime(from); Calendar before = Calendar.getInstance(); before.setTime(to); if (date.after(after) && date.before(before)) { return true; } else { return false; } }