I am writing a project which handles card reading for door passing. The system must check if the swiped card has permission to a specific door at that specific time. For example, some cards do not have permission during weekends or outside working hours which are 8-20. How do I program such a thing with Joda-Time?
Right now I have:
//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
Using 1 <= time.getDayOfWeek() && time.getDayOfWeek() <= 5
You can ensure that the day of the week is between Monday 1
and Friday 5
.