问题:我有一个包含小时数的列表,例如:08:15:00 08:45:00 09:00:00 12:00:00 ...应用程序允许用户预约特定时间: 8:15:00,每次开会半小时。
问题:如何确定这样的预约是否需要空档?我知道 Calendar 类有 before() 和 after() 方法,但它不能解决我的问题。我的意思是如果12:00有预约,12:00有预约,那么在12:15再预约之前如何预防?
编辑:
我尝试过使用我之前提到的方法,例如:
Calendar cal1 = Calendar.getInstance(); // for example 12:00:00
Calendar cal2 = Calendar.getInstance(); // for exmaple 12:30:00
Calendar userTime = Calendar.getInstance(); // time to test: 12:15:00
if(user.after(cal1)&& user.before(cal2)){
... // do sth
}