我正在写一个处理读卡门牌的项目。系统必须检查刷卡是否在该特定时间对特定门具有许可。例如,有些卡在周末或工作时间以外是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
答案 0 :(得分:1)
使用1 <= time.getDayOfWeek() && time.getDayOfWeek() <= 5
您可以确保星期几在1
星期一到星期五5
之间。