List of usage examples for org.joda.time DateTime withDayOfWeek
public DateTime withDayOfWeek(int dayOfWeek)
From source file:eafit.cdei.asignacion.input.ReadTeacherAvailability.java
private List<TimeDayLocation> generateMTF(String location, String startH, String endH) { ArrayList<TimeDayLocation> avaliability = new ArrayList<>(); if (location != null) { TimeDayLocation tdlM = new TimeDayLocation(); TimeDayLocation tdlT = new TimeDayLocation(); TimeDayLocation tdlW = new TimeDayLocation(); TimeDayLocation tdlTH = new TimeDayLocation(); TimeDayLocation tdlF = new TimeDayLocation(); DateTime now = new DateTime(); tdlM.setDow(now.withDayOfWeek(DateTimeConstants.MONDAY)); tdlT.setDow(now.withDayOfWeek(DateTimeConstants.TUESDAY)); tdlW.setDow(now.withDayOfWeek(DateTimeConstants.WEDNESDAY)); tdlTH.setDow(now.withDayOfWeek(DateTimeConstants.THURSDAY)); tdlF.setDow(now.withDayOfWeek(DateTimeConstants.FRIDAY)); avaliability.add(tdlM);/*from w w w . j a v a2 s . c o m*/ avaliability.add(tdlT); avaliability.add(tdlW); avaliability.add(tdlTH); avaliability.add(tdlF); repeatTime(avaliability, startH, endH); } return avaliability; }
From source file:eafit.cdei.asignacion.input.ReadTeacherAvailability.java
private List<TimeDayLocation> generateMWF(String location, String startH, String endH) { ArrayList<TimeDayLocation> avaliability = new ArrayList<>(); if (location != null) { TimeDayLocation tdlM = new TimeDayLocation(); TimeDayLocation tdlW = new TimeDayLocation(); TimeDayLocation tdlF = new TimeDayLocation(); DateTime now = new DateTime(); tdlM.setDow(now.withDayOfWeek(DateTimeConstants.MONDAY)); tdlW.setDow(now.withDayOfWeek(DateTimeConstants.WEDNESDAY)); tdlF.setDow(now.withDayOfWeek(DateTimeConstants.FRIDAY)); avaliability.add(tdlM);//from ww w . ja v a 2 s . c om avaliability.add(tdlW); avaliability.add(tdlF); repeatTime(avaliability, startH, endH); } return avaliability; }
From source file:eafit.cdei.asignacion.input.ReadTeacherAvailability.java
private List<TimeDayLocation> generateWF(String location, String startH, String endH) { ArrayList<TimeDayLocation> avaliability = new ArrayList<>(); if (location != null) { TimeDayLocation tdlW = new TimeDayLocation(); TimeDayLocation tdlF = new TimeDayLocation(); DateTime now = new DateTime(); tdlW.setDow(now.withDayOfWeek(DateTimeConstants.WEDNESDAY)); tdlF.setDow(now.withDayOfWeek(DateTimeConstants.FRIDAY)); avaliability.add(tdlW);/* www .jav a 2 s . c om*/ avaliability.add(tdlF); repeatTime(avaliability, startH, endH); } return avaliability; }
From source file:eafit.cdei.asignacion.input.ReadTeacherAvailability.java
private List<TimeDayLocation> generateWF(String location, String startH, String startMinute, String endH, String endMinute) {// w w w. j a v a2 s . c o m ArrayList<TimeDayLocation> avaliability = new ArrayList<>(); if (location != null) { TimeDayLocation tdlW = new TimeDayLocation(); TimeDayLocation tdlF = new TimeDayLocation(); DateTime now = new DateTime(); tdlW.setDow(now.withDayOfWeek(DateTimeConstants.WEDNESDAY)); tdlF.setDow(now.withDayOfWeek(DateTimeConstants.FRIDAY)); avaliability.add(tdlW); avaliability.add(tdlF); repeatTime(avaliability, startH, startMinute, endH, endMinute); } return avaliability; }
From source file:eafit.cdei.asignacion.input.ReadTeacherAvailability.java
private List<TimeDayLocation> generateMTT(String location, String startH, String startMinute, String endH, String endMinute) {// w ww.j a v a 2 s .com ArrayList<TimeDayLocation> avaliability = new ArrayList<>(); if (location != null) { TimeDayLocation tdlM = new TimeDayLocation(); TimeDayLocation tdlT = new TimeDayLocation(); TimeDayLocation tdlW = new TimeDayLocation(); TimeDayLocation tdlTH = new TimeDayLocation(); DateTime now = new DateTime(); tdlM.setDow(now.withDayOfWeek(DateTimeConstants.MONDAY)); tdlT.setDow(now.withDayOfWeek(DateTimeConstants.TUESDAY)); tdlW.setDow(now.withDayOfWeek(DateTimeConstants.WEDNESDAY)); tdlTH.setDow(now.withDayOfWeek(DateTimeConstants.THURSDAY)); avaliability.add(tdlM); avaliability.add(tdlT); avaliability.add(tdlW); avaliability.add(tdlTH); repeatTime(avaliability, startH, startMinute, endH, endMinute); } return avaliability; }
From source file:eafit.cdei.asignacion.input.ReadTeacherAvailability.java
private List<TimeDayLocation> generateMTW(String location, String startH, String startMinute, String endH, String endMinute) {/*from w w w .j av a2 s .c om*/ ArrayList<TimeDayLocation> avaliability = new ArrayList<>(); if (location != null) { TimeDayLocation tdlM = new TimeDayLocation(); TimeDayLocation tdlT = new TimeDayLocation(); TimeDayLocation tdlW = new TimeDayLocation(); DateTime now = new DateTime(); tdlM.setDow(now.withDayOfWeek(DateTimeConstants.MONDAY)); tdlT.setDow(now.withDayOfWeek(DateTimeConstants.TUESDAY)); tdlW.setDow(now.withDayOfWeek(DateTimeConstants.WEDNESDAY)); avaliability.add(tdlM); avaliability.add(tdlT); avaliability.add(tdlW); repeatTime(avaliability, startH, startMinute, endH, endMinute); } return avaliability; }
From source file:eafit.cdei.asignacion.input.ReadTeacherAvailability.java
private List<TimeDayLocation> generateTTT(String location, String startH, String startMinute, String endH, String endMinute) {/*w w w.jav a 2 s . c om*/ ArrayList<TimeDayLocation> avaliability = new ArrayList<>(); if (location != null) { TimeDayLocation tdlT = new TimeDayLocation(); TimeDayLocation tdlTH = new TimeDayLocation(); DateTime now = new DateTime(); tdlT.setDow(now.withDayOfWeek(DateTimeConstants.TUESDAY)); tdlTH.setDow(now.withDayOfWeek(DateTimeConstants.THURSDAY)); avaliability.add(tdlT); avaliability.add(tdlTH); repeatTime(avaliability, startH, startMinute, endH, endMinute); } return avaliability; }
From source file:eafit.cdei.asignacion.input.ReadTeacherAvailability.java
private List<TimeDayLocation> generateTTT(String location, String startH, String endH) { ArrayList<TimeDayLocation> avaliability = new ArrayList<>(); if (location != null) { TimeDayLocation tdlT = new TimeDayLocation(); TimeDayLocation tdlTH = new TimeDayLocation(); DateTime now = new DateTime(); tdlT.setDow(now.withDayOfWeek(DateTimeConstants.TUESDAY)); tdlTH.setDow(now.withDayOfWeek(DateTimeConstants.THURSDAY)); avaliability.add(tdlT);/*from w w w . ja v a2 s.com*/ avaliability.add(tdlTH); repeatTime(avaliability, startH, endH); } return avaliability; }
From source file:io.apiman.manager.api.core.metrics.AbstractMetricsAccessor.java
License:Apache License
/** * Based on the given interval, create a "floor" value relative to the * given date. This basically means zero'ing out certain fields (different * fields based on the interval type) and returning the modified date. * @param date/* w w w . j av a 2s. c o m*/ * @param interval */ protected static DateTime floor(DateTime date, HistogramIntervalType interval) { DateTime rval = date.withMillisOfSecond(0); switch (interval) { case day: rval = rval.withHourOfDay(0).withMinuteOfHour(0).withSecondOfMinute(0); break; case hour: rval = rval.withMinuteOfHour(0).withSecondOfMinute(0); break; case minute: rval = rval.withSecondOfMinute(0); break; case month: rval = rval.withDayOfMonth(1).withHourOfDay(0).withMinuteOfHour(0).withSecondOfMinute(0); break; case week: rval = rval.withDayOfWeek(DateTimeConstants.MONDAY).withHourOfDay(0).withMinuteOfHour(0) .withSecondOfMinute(0); break; } return rval; }
From source file:net.sourceforge.fenixedu.presentationTier.Action.resourceAllocationManager.ViewAllRoomsSchedulesDA.java
License:Open Source License
public ActionForward downloadRoomLessonOccupationInfo(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException { final ExecutionSemester executionSemester = getExecutionSemester(request); final ExecutionYear executionYear = executionSemester.getExecutionYear(); response.setContentType("application/vnd.ms-excel"); response.setHeader("Content-disposition", "attachment; filename=occupationMap" + executionYear.getYear().replace('/', '_') + "_" + executionSemester.getSemester() + ".xls"); final RoomMap occupationMap = new RoomMap(); Space.getSpaces().forEach(s -> occupationMap.register(s)); for (final ExecutionCourse executionCourse : executionSemester.getAssociatedExecutionCoursesSet()) { for (final CourseLoad courseLoad : executionCourse.getCourseLoadsSet()) { for (final Shift shift : courseLoad.getShiftsSet()) { for (final Lesson lesson : shift.getAssociatedLessonsSet()) { occupationMap.register(lesson); }//from w w w . j av a2 s. c o m } } } final Spreadsheet spreadsheet = new Spreadsheet("OccupationMap"); spreadsheet.setHeader(BundleUtil.getString(Bundle.APPLICATION, "label.building")); spreadsheet.setHeader(BundleUtil.getString(Bundle.APPLICATION, "label.identification")); spreadsheet.setHeader(BundleUtil.getString(Bundle.APPLICATION, "label.blueprintNumber")); spreadsheet.setHeader(BundleUtil.getString(Bundle.APPLICATION, "label.doorNumber")); spreadsheet.setHeader(BundleUtil.getString(Bundle.APPLICATION, "label.description")); spreadsheet.setHeader(BundleUtil.getString(Bundle.APPLICATION, "label.classification")); final DateTime now = new DateTime(); for (int weekDay = 0; weekDay < 6; weekDay++) { final DateTime dateTime = now.withDayOfWeek(weekDay + 1); final String weekDayString = dateTime.dayOfWeek().getAsText(I18N.getLocale()); for (int hour = 0; hour < 16; hour++) { spreadsheet.setHeader(weekDayString + " " + (hour + 8) + ":00"); spreadsheet.setHeader(weekDayString + " " + (hour + 8) + ":30"); } } for (final Entry<Space, boolean[][]> entry : occupationMap.entrySet()) { final Space space = entry.getKey(); final String identification = space.getName(); final Space building = SpaceUtils.getSpaceBuilding(space); final String buildingName = building == null ? "" : building.getPresentationName(); final boolean[][] slots = entry.getValue(); final Row row = spreadsheet.addRow(); row.setCell(buildingName); row.setCell(identification == null ? " " : identification); final String blueprintNumber = findClosestBlueprintNumber(space); row.setCell(blueprintNumber); if (SpaceUtils.isRoom(space)) { Optional<String> doorNumber = space.getMetadata("doorNumber"); Optional<String> description = space.getMetadata("description"); row.setCell(doorNumber.isPresent() ? doorNumber.get() : " "); row.setCell(description.isPresent() ? description.get() : " "); } else if (SpaceUtils.isRoomSubdivision(space)) { final Space room = findSurroundingRoom(space); if (room == null) { row.setCell(" "); row.setCell(" "); } else { Optional<String> doorNumber = space.getMetadata("doorNumber"); Optional<String> description = space.getMetadata("description"); row.setCell(doorNumber.isPresent() ? doorNumber.get() : " "); row.setCell(description.isPresent() ? description.get() : " "); } } else { row.setCell(" "); row.setCell(" "); } SpaceClassification classification = space.getClassification(); if (classification == null) { row.setCell(" "); } else { row.setCell(classification.getAbsoluteCode() + " " + classification.getName().getContent()); } for (int i = 0; i < WEEKDAY_COUNT; i++) { for (int j = 0; j < HOUR_COUNT; j++) { row.setCell(Boolean.toString(slots[i][j])); } } } final ServletOutputStream writer = response.getOutputStream(); spreadsheet.exportToXLSSheet(writer); writer.flush(); response.flushBuffer(); return null; }