List of usage examples for org.joda.time YearMonthDay plusDays
public YearMonthDay plusDays(int days)
From source file:net.sourceforge.fenixedu.applicationTier.Servico.resourceAllocationManager.DeleteLessonInstance.java
License:Open Source License
@Atomic public static void run(final SortedSet<NextPossibleSummaryLessonsAndDatesBean> set) { final NextPossibleSummaryLessonsAndDatesBean last = set.last(); final Lesson lesson = last.getLesson(); final YearMonthDay date = last.getDate(); lesson.refreshPeriodAndInstancesInSummaryCreation( lesson.isBiWeeklyOffset() ? date.plusDays(8) : date.plusDays(1)); for (final NextPossibleSummaryLessonsAndDatesBean n : set) { run(n.getLesson(), n.getDate()); }// w w w. j ava 2 s . c o m }
From source file:net.sourceforge.fenixedu.dataTransferObject.spaceManager.ViewEventSpaceOccupationsBean.java
License:Open Source License
public ViewEventSpaceOccupationsBean(YearMonthDay day, Space allocatableSpace) { setAllocatableSpace(allocatableSpace); if (day != null) { setYear(new Partial(DateTimeFieldType.year(), day.getYear())); setMonth(new Partial(DateTimeFieldType.monthOfYear(), day.getMonthOfYear())); YearMonthDay monday = day.toDateTimeAtMidnight().withDayOfWeek(MONDAY_IN_JODA_TIME).toYearMonthDay(); if ((monday.getMonthOfYear() < day.getMonthOfYear()) || (monday.getYear() < day.getYear())) { monday = monday.plusDays(Lesson.NUMBER_OF_DAYS_IN_WEEK); }//w ww . j ava 2 s . com setDay(monday); } }
From source file:net.sourceforge.fenixedu.domain.Lesson.java
License:Open Source License
private YearMonthDay getValidBeginDate(YearMonthDay startDate) { YearMonthDay lessonBegin = startDate.toDateTimeAtMidnight() .withDayOfWeek(getDiaSemana().getDiaSemanaInDayOfWeekJodaFormat()).toYearMonthDay(); if (lessonBegin.isBefore(startDate)) { lessonBegin = lessonBegin.plusDays(NUMBER_OF_DAYS_IN_WEEK); }/*from w w w. jav a 2s .co m*/ return lessonBegin; }
From source file:net.sourceforge.fenixedu.domain.Lesson.java
License:Open Source License
private SortedSet<YearMonthDay> getAllValidLessonDatesWithoutInstancesDates(YearMonthDay startDateToSearch, YearMonthDay endDateToSearch) {// w w w . j a v a 2 s . com SortedSet<YearMonthDay> result = new TreeSet<YearMonthDay>(); startDateToSearch = startDateToSearch != null ? getValidBeginDate(startDateToSearch) : null; if (!wasFinished() && startDateToSearch != null && endDateToSearch != null && !startDateToSearch.isAfter(endDateToSearch)) { Space lessonCampus = getLessonCampus(); final int dayIncrement = getFrequency() == FrequencyType.BIWEEKLY ? FrequencyType.WEEKLY.getNumberOfDays() : getFrequency().getNumberOfDays(); boolean shouldAdd = true; while (true) { if (isDayValid(startDateToSearch, lessonCampus)) { if (getFrequency() != FrequencyType.BIWEEKLY || shouldAdd) { if (!isHoliday(startDateToSearch, lessonCampus)) { result.add(startDateToSearch); } } shouldAdd = !shouldAdd; } startDateToSearch = startDateToSearch.plusDays(dayIncrement); if (startDateToSearch.isAfter(endDateToSearch)) { break; } } } return result; }
From source file:net.sourceforge.fenixedu.domain.LessonInstance.java
License:Open Source License
private YearMonthDay findNextPossibleDateAfter(YearMonthDay day, Lesson lesson) { for (YearMonthDay lessonDay : lesson.getAllLessonDatesWithoutInstanceDates()) { if (lessonDay.isAfter(day)) { return lessonDay; }/* ww w . ja va2 s . c om*/ } return lesson.isBiWeeklyOffset() ? day.plusDays(8) : day.plusDays(1); }
From source file:net.sourceforge.fenixedu.domain.space.EventSpaceOccupation.java
License:Open Source License
public static List<Interval> generateEventSpaceOccupationIntervals(YearMonthDay begin, final YearMonthDay end, final HourMinuteSecond beginTime, final HourMinuteSecond endTime, final FrequencyType frequency, final DiaSemana diaSemana, final Boolean dailyFrequencyMarkSaturday, final Boolean dailyFrequencyMarkSunday, final YearMonthDay startDateToSearch, final YearMonthDay endDateToSearch) { List<Interval> result = new ArrayList<Interval>(); begin = getBeginDateInSpecificWeekDay(diaSemana, begin); if (frequency == null) { if (!begin.isAfter(end) && (startDateToSearch == null || (!end.isBefore(startDateToSearch) && !begin.isAfter(endDateToSearch)))) { result.add(createNewInterval(begin, end, beginTime, endTime)); return result; }//from w w w . jav a 2s . c o m } else { int numberOfDaysToSum = frequency.getNumberOfDays(); while (true) { if (begin.isAfter(end)) { break; } if (startDateToSearch == null || (!begin.isBefore(startDateToSearch) && !begin.isAfter(endDateToSearch))) { Interval interval = createNewInterval(begin, begin, beginTime, endTime); if (!frequency.equals(FrequencyType.DAILY) || ((dailyFrequencyMarkSaturday || interval.getStart().getDayOfWeek() != SATURDAY_IN_JODA_TIME) && (dailyFrequencyMarkSunday || interval.getStart().getDayOfWeek() != SUNDAY_IN_JODA_TIME))) { result.add(interval); } } begin = begin.plusDays(numberOfDaysToSum); } } return result; }
From source file:net.sourceforge.fenixedu.domain.space.EventSpaceOccupation.java
License:Open Source License
protected DateTime getInstant(boolean firstInstant, YearMonthDay begin, final YearMonthDay end, final HourMinuteSecond beginTime, final HourMinuteSecond endTime, final FrequencyType frequency, final DiaSemana diaSemana, final Boolean dailyFrequencyMarkSaturday, final Boolean dailyFrequencyMarkSunday) { DateTime instantResult = null;/* w w w . j av a 2s . c om*/ begin = getBeginDateInSpecificWeekDay(diaSemana, begin); if (frequency == null) { if (!begin.isAfter(end)) { if (firstInstant) { return begin.toDateTime(new TimeOfDay(beginTime.getHour(), beginTime.getMinuteOfHour(), 0, 0)); } else { return end.toDateTime(new TimeOfDay(endTime.getHour(), endTime.getMinuteOfHour(), 0, 0)); } } } else { int numberOfDaysToSum = frequency.getNumberOfDays(); while (true) { if (begin.isAfter(end)) { break; } DateTime intervalEnd = begin .toDateTime(new TimeOfDay(endTime.getHour(), endTime.getMinuteOfHour(), 0, 0)); if (!frequency.equals(FrequencyType.DAILY) || ((dailyFrequencyMarkSaturday || intervalEnd.getDayOfWeek() != SATURDAY_IN_JODA_TIME) && (dailyFrequencyMarkSunday || intervalEnd.getDayOfWeek() != SUNDAY_IN_JODA_TIME))) { if (firstInstant) { return begin .toDateTime(new TimeOfDay(beginTime.getHour(), beginTime.getMinuteOfHour(), 0, 0)); } else { instantResult = intervalEnd; } } begin = begin.plusDays(numberOfDaysToSum); } } return instantResult; }
From source file:net.sourceforge.fenixedu.domain.space.EventSpaceOccupation.java
License:Open Source License
private static YearMonthDay getBeginDateInSpecificWeekDay(DiaSemana diaSemana, YearMonthDay begin) { if (diaSemana != null) { YearMonthDay newBegin = begin.toDateTimeAtMidnight() .withDayOfWeek(diaSemana.getDiaSemanaInDayOfWeekJodaFormat()).toYearMonthDay(); if (newBegin.isBefore(begin)) { begin = newBegin.plusDays(Lesson.NUMBER_OF_DAYS_IN_WEEK); } else {// w ww .j a va2s . co m begin = newBegin; } } return begin; }
From source file:net.sourceforge.fenixedu.domain.student.SeparationCyclesManagement.java
License:Open Source License
private YearMonthDay getBeginDate(final StudentCurricularPlan sourceStudentCurricularPlan, final ExecutionSemester executionSemester) { if (!sourceStudentCurricularPlan.getRegistration().hasConcluded()) { throw new DomainException( "error.SeparationCyclesManagement.source.studentCurricularPlan.is.not.concluded"); }//from w ww. ja v a2s . c om final YearMonthDay conclusionDate = sourceStudentCurricularPlan.getFirstCycle().calculateConclusionDate(); final YearMonthDay stateDate = conclusionDate != null ? conclusionDate.plusDays(1) : new YearMonthDay().plusDays(1); return executionSemester.getBeginDateYearMonthDay().isBefore(stateDate) ? stateDate : executionSemester.getBeginDateYearMonthDay(); }
From source file:net.sourceforge.fenixedu.presentationTier.Action.publico.scientificalArea.PublicScientificAreaSiteDA.java
License:Open Source License
public ActionForward viewTeachers(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) {//w w w .j a v a 2 s . co m ScientificAreaUnit scientificArea = (ScientificAreaUnit) getUnit(request); YearMonthDay today = new YearMonthDay(); YearMonthDay tomorrow = today.plusDays(1); SortedSet<ProfessionalCategory> categories = new TreeSet<ProfessionalCategory>(); Map<String, SortedSet<Person>> teachers = new Hashtable<String, SortedSet<Person>>(); for (Teacher teacher : scientificArea.getDepartmentUnit().getDepartment().getAllTeachers(today, tomorrow)) { if (teacher.getCurrentSectionOrScientificArea() == scientificArea) { ProfessionalCategory professionalCategory = teacher.getCategory(); if (professionalCategory != null) { String category = professionalCategory.getExternalId(); categories.add(professionalCategory); addListTeacher(teachers, category, teacher); } } } request.setAttribute("categories", categories); request.setAttribute("teachers", teachers); return mapping.findForward("view-teachers"); }