/** * Create a busy profile with office hours. The method returns the * the available hours, inside office hours. * By default, the office hours are from Monday-Friday, 09:00-17:00, with * time zone CET. * @param timeMin * @param timeMax * @return available */ public static List<Interval> getOfficeHours(DateTime timeMin, DateTime timeMax) { Set<Integer> workingDays = new HashSet<Integer>(); // 1=Monday, 7=Sunday workingDays.add(1); // Monday workingDays.add(2); // Tuesday workingDays.add(3); // Wednesday workingDays.add(4); // Thursday workingDays.add(5); // Friday int hourStart = 9; int hourEnd = 17; DateTimeZone timeZone = DateTimeZone.forID("CET"); // Central European Time return getOfficeHours(timeMin, timeMax, workingDays, hourStart, hourEnd, timeZone); }
List<Interval> officeHours = IntervalsUtil.getOfficeHours(timeMin, timeMax); for (Interval i : officeHours) { IntervalsUtil.order(infeasibleIntervals); getState().put("infeasible", infeasibleIntervals); WeightsUtil.order(preferredIntervals);
List<Weight> mergedPreferred = null; if (infeasible != null) { mergedInfeasible = IntervalsUtil.merge(infeasible);
public ArrayNode getOfficeHours(@Name("timeMin") String timeMin, @Name("timeMax") String timeMax) { List<Interval> available = IntervalsUtil.getOfficeHours(new DateTime( timeMin), new DateTime(timeMax)); // convert to JSON array ArrayNode array = JOM.createArrayNode(); for (Interval interval : available) { ObjectNode obj = JOM.createObjectNode(); obj.put("start", interval.getStart().toString()); obj.put("end", interval.getEnd().toString()); array.add(obj); } return array; }