我正在写一个项目,处理门禁读卡器。系统必须检查被刷卡在那个特定时间是否有权限进入特定的门。例如,一些卡在周末或工作时间为8-20的非工作时间没有权限。我如何用Joda-Time来编写这样的程序呢?
现在我有:
//The code below that I have only checks for within a given date and time range.
DateTime start = new DateTime(2012, 1, 1, 0, 0);
DateTime end = new DateTime(2012, 12, 31, 0, 0);
Interval interval = new Interval(start, end);
boolean DateTimeCheck3 = interval.contains(time); // time is predeclared and gets current time from another class发布于 2012-08-14 14:36:04
使用1 <= time.getDayOfWeek() && time.getDayOfWeek() <= 5,您可以确保一周中的某一天在星期一1和星期五5之间。
https://stackoverflow.com/questions/11943382
复制相似问题