2

我正在编写一个项目来处理通过门的读卡器。系统必须检查在特定时间刷卡是否有权进入特定门。例如,有些卡在周末或 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
4

1 回答 1

1

使用1 <= time.getDayOfWeek() && time.getDayOfWeek() <= 5您可以确保星期几在星期一1和星期五之间5

于 2012-08-14T06:36:04.383 回答