org.joda.time.YearMonthDay Java Examples

The following examples show how to use org.joda.time.YearMonthDay. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RaidesSpecializationReportFile.java    From fenixedu-academic with GNU Lesser General Public License v3.0 6 votes vote down vote up
private void reportRaides(final Spreadsheet sheet, final Registration registration,
        StudentCurricularPlan studentCurricularPlan, List<Registration> registrationPath,
        ExecutionYear executionYear, final CycleType cycleType, final boolean concluded, final YearMonthDay conclusionDate) {

    final Row row =
            RaidesCommonReportFieldsWrapper.reportRaidesFields(sheet, registration, studentCurricularPlan, registrationPath,
                    executionYear, cycleType, concluded, conclusionDate, null, false);

    // Total de ECTS concluídos até ao fim do ano lectivo anterior ao que se referem os dados  no curso actual
    double totalEctsConcludedUntilPreviousYear = studentCurricularPlan.getInternalCycleCurriculumGrops().stream()
            .mapToDouble(cycleCurriculumGroup -> cycleCurriculumGroup.getCreditsConcluded(executionYear.getPreviousExecutionYear()))
            .sum();

    // Total de ECTS necessários para a conclusão
    if (concluded) {
        row.setCell(0);
    } else {
        row.setCell(studentCurricularPlan.getRoot().getDefaultEcts(executionYear) - totalEctsConcludedUntilPreviousYear);
    }
}
 
Example #2
Source File: LessonInstanceSpaceOccupation.java    From fenixedu-academic with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public List<Interval> getEventSpaceOccupationIntervals(YearMonthDay startDateToSearch, YearMonthDay endDateToSearch) {

    List<Interval> result = new ArrayList<Interval>();
    Collection<LessonInstance> lessonInstances = getLessonInstancesSet();

    DateTime startDateTime = startDateToSearch != null ? startDateToSearch.toDateTimeAtMidnight() : null;
    DateTime endDateTime = endDateToSearch != null ? endDateToSearch.toDateTime(new TimeOfDay(23, 59, 59)) : null;

    for (LessonInstance lessonInstance : lessonInstances) {
        if (startDateTime == null
                || (!lessonInstance.getEndDateTime().isBefore(startDateTime) && !lessonInstance.getBeginDateTime().isAfter(
                        endDateTime))) {

            result.add(new Interval(lessonInstance.getBeginDateTime(), lessonInstance.getEndDateTime()));
        }
    }
    return result;
}
 
Example #3
Source File: Person.java    From fenixedu-academic with GNU Lesser General Public License v3.0 6 votes vote down vote up
private void logSetterNullYearMonthDay(String keyInfoType, YearMonthDay oldValue, YearMonthDay newValue, String keyLabel) {
    Object argNew, argOld;
    String strNew, strOld;
    argOld = valueToUpdateIfNewNotNull(BundleUtil.getString(Bundle.HTML, "text.dateEmpty"), oldValue);
    argNew = valueToUpdateIfNewNotNull(BundleUtil.getString(Bundle.HTML, "text.dateEmpty"), newValue);

    if (argOld instanceof YearMonthDay) {
        strOld = ((YearMonthDay) argOld).toString("yyyy/MM/dd");
    } else {
        strOld = (String) argOld;
    }

    if (argNew instanceof YearMonthDay) {
        strNew = ((YearMonthDay) argNew).toString("yyyy/MM/dd");
    } else {
        strNew = (String) argNew;
    }
    logSetter(keyInfoType, strOld, strNew, keyLabel);
}
 
Example #4
Source File: SearchAllActiveInternalUnits.java    From fenixedu-academic with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
protected Collection search(String value, int size) {
    Collection<UnitName> units = super.search(value, size);

    List<Unit> result = new ArrayList<Unit>();
    YearMonthDay now = new YearMonthDay();

    for (UnitName unitName : units) {
        Unit unit = unitName.getUnit();
        if (unit.isActive(now)) {
            result.add(unit);
        }
    }

    return result;
}
 
Example #5
Source File: AcademicCalendarsManagementDA.java    From fenixedu-academic with GNU Lesser General Public License v3.0 6 votes vote down vote up
public ActionForward prepareCreateAcademicCalendar(ActionMapping mapping, ActionForm actionForm, HttpServletRequest request,
        HttpServletResponse response) throws Exception {

    ExecutionYear currentExecutionYear = ExecutionYear.readCurrentExecutionYear();
    Partial begin;
    Partial end;
    if (currentExecutionYear != null) {
        begin = CalendarEntryBean.getPartialFromYearMonthDay(currentExecutionYear.getBeginDateYearMonthDay());
        end = CalendarEntryBean.getPartialFromYearMonthDay(currentExecutionYear.getEndDateYearMonthDay());
    } else {
        begin = CalendarEntryBean.getPartialFromYearMonthDay(new YearMonthDay());
        end = CalendarEntryBean.getPartialFromYearMonthDay(new YearMonthDay().plusMonths(3));
    }

    CalendarEntryBean bean = CalendarEntryBean.createAcademicCalendarBean(begin, end);
    request.setAttribute("parentEntryBean", bean);

    return mapping.findForward("prepareCreateCalendarEntry");
}
 
Example #6
Source File: Dismissal.java    From fenixedu-academic with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public YearMonthDay calculateConclusionDate() {

    if (getCredits().getOfficialDate() != null) {
        return new YearMonthDay(getCredits().getOfficialDate());
    }

    final SortedSet<IEnrolment> iEnrolments = new TreeSet<IEnrolment>(IEnrolment.COMPARATOR_BY_APPROVEMENT_DATE);
    iEnrolments.addAll(getSourceIEnrolments());

    final YearMonthDay beginDate = getExecutionPeriod().getBeginDateYearMonthDay();
    if (!iEnrolments.isEmpty()) {
        final IEnrolment enrolment = iEnrolments.last();
        final YearMonthDay approvementDate = enrolment.getApprovementDate();
        return approvementDate != null ? approvementDate : beginDate;
    } else {
        return beginDate;
    }
}
 
Example #7
Source File: TestGJChronology.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
private void testAdd(String start, DurationFieldType type, int amt, String end) {
    DateTime dtStart = new DateTime(start, GJChronology.getInstance(DateTimeZone.UTC));
    DateTime dtEnd = new DateTime(end, GJChronology.getInstance(DateTimeZone.UTC));
    assertEquals(dtEnd, dtStart.withFieldAdded(type, amt));
    assertEquals(dtStart, dtEnd.withFieldAdded(type, -amt));

    DurationField field = type.getField(GJChronology.getInstance(DateTimeZone.UTC));
    int diff = field.getDifference(dtEnd.getMillis(), dtStart.getMillis());
    assertEquals(amt, diff);
    
    if (type == DurationFieldType.years() ||
        type == DurationFieldType.months() ||
        type == DurationFieldType.days()) {
        YearMonthDay ymdStart = new YearMonthDay(start, GJChronology.getInstance(DateTimeZone.UTC));
        YearMonthDay ymdEnd = new YearMonthDay(end, GJChronology.getInstance(DateTimeZone.UTC));
        assertEquals(ymdEnd, ymdStart.withFieldAdded(type, amt));
        assertEquals(ymdStart, ymdEnd.withFieldAdded(type, -amt));
    }
}
 
Example #8
Source File: Qualification.java    From fenixedu-academic with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Deprecated
public void setEquivalenceDate(java.util.Date date) {
    if (date == null) {
        setEquivalenceDateYearMonthDay(null);
    } else {
        setEquivalenceDateYearMonthDay(org.joda.time.YearMonthDay.fromDateFields(date));
    }
}
 
Example #9
Source File: Lesson.java    From fenixedu-academic with GNU Lesser General Public License v3.0 5 votes vote down vote up
private boolean contains(Interval interval, SortedSet<YearMonthDay> allLessonDates) {

        YearMonthDay intervalStartDate = interval.getStart().toYearMonthDay();
        YearMonthDay intervalEndDate = interval.getEnd().toYearMonthDay();

        HourMinuteSecond intervalBegin =
                new HourMinuteSecond(interval.getStart().getHourOfDay(), interval.getStart().getMinuteOfHour(), interval
                        .getStart().getSecondOfMinute());
        HourMinuteSecond intervalEnd =
                new HourMinuteSecond(interval.getEnd().getHourOfDay(), interval.getEnd().getMinuteOfHour(), interval.getEnd()
                        .getSecondOfMinute());

        for (YearMonthDay day : allLessonDates) {
            if (intervalStartDate.isEqual(intervalEndDate)) {
                if (day.isEqual(intervalStartDate) && !intervalBegin.isAfter(getEndHourMinuteSecond())
                        && !intervalEnd.isBefore(getBeginHourMinuteSecond())) {
                    return true;
                }
            } else {
                if ((day.isAfter(intervalStartDate) && day.isBefore(intervalEndDate)) || day.isEqual(intervalStartDate)
                        && !getEndHourMinuteSecond().isBefore(intervalBegin)
                        || (day.isEqual(intervalEndDate) && !getBeginHourMinuteSecond().isAfter(intervalEnd))) {
                    return true;
                }
            }
        }
        return false;
    }
 
Example #10
Source File: Lesson.java    From fenixedu-academic with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void refreshPeriodAndInstancesInEditOperation(YearMonthDay newBeginDate, YearMonthDay newEndDate,
        Boolean createLessonInstances, GenericPair<YearMonthDay, YearMonthDay> maxLessonsPeriod) {

    removeExistentInstancesWithoutSummaryAfterOrEqual(newBeginDate);
    SortedSet<YearMonthDay> instanceDates =
            getAllLessonInstancesDatesToCreate(getLessonStartDay(), newBeginDate.minusDays(1), createLessonInstances);
    refreshPeriod(newBeginDate, newEndDate);
    createAllLessonInstances(instanceDates);
}
 
Example #11
Source File: PartialRegimeInstallment.java    From fenixedu-academic with GNU Lesser General Public License v3.0 5 votes vote down vote up
public PartialRegimeInstallment(FullGratuityPaymentPlanForPartialRegime paymentPlan, Money amount, YearMonthDay startDate,
        YearMonthDay endDate, BigDecimal penaltyPercentage, YearMonthDay whenStartToApplyPenalty,
        Integer maxMonthsToApplyPenalty, BigDecimal ectsForAmount, List<ExecutionSemester> executionSemesters) {
    this();
    init(paymentPlan, amount, startDate, endDate, true, penaltyPercentage, whenStartToApplyPenalty, maxMonthsToApplyPenalty,
            ectsForAmount, executionSemesters);
}
 
Example #12
Source File: Lesson.java    From fenixedu-academic with GNU Lesser General Public License v3.0 5 votes vote down vote up
public SortedSet<YearMonthDay> getAllLessonDatesUntil(YearMonthDay day) {
    SortedSet<YearMonthDay> result = new TreeSet<YearMonthDay>();
    if (day != null) {
        result.addAll(getAllLessonInstanceDatesUntil(day));
        if (!wasFinished()) {
            YearMonthDay startDateToSearch = getLessonStartDay();
            YearMonthDay lessonEndDay = getLessonEndDay();
            YearMonthDay endDateToSearch = (lessonEndDay.isAfter(day)) ? day : lessonEndDay;
            result.addAll(getAllValidLessonDatesWithoutInstancesDates(startDateToSearch, endDateToSearch));
        }
    }
    return result;
}
 
Example #13
Source File: RegistrationOperation.java    From fenixedu-academic with GNU Lesser General Public License v3.0 5 votes vote down vote up
protected void enrolStudentInCurricularCourses(final ExecutionDegree executionDegree, final Registration registration) {
    final ExecutionSemester executionSemester = getExecutionPeriod();
    final StudentCurricularPlan studentCurricularPlan =
            StudentCurricularPlan.createBolonhaStudentCurricularPlan(registration, executionDegree.getDegreeCurricularPlan(),
                    new YearMonthDay(), executionSemester);

    studentCurricularPlan.createFirstTimeStudentEnrolmentsFor(executionSemester, getCurrentUsername());
    registration.updateEnrolmentDate(executionSemester.getExecutionYear());
}
 
Example #14
Source File: UnitsTree.java    From fenixedu-academic with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void getSubUnitsList(Unit parentUnit, Unit parentUnitParent, StringBuilder buffer, YearMonthDay currentDate,
        String paramName, String path) {

    buffer.append("<li>");

    HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();
    List<Unit> subUnits = getUnitSubUnits(parentUnit, currentDate);
    if (!subUnits.isEmpty()) {
        putImage(parentUnit, parentUnitParent, buffer, request);
    }

    buffer.append("<a href=\"").append(request.getContextPath()).append(path).append("&").append(paramName).append("=")
            .append(parentUnit.getExternalId()).append("\">").append(parentUnit.getNameWithAcronym()).append("</a>")
            .append("</li>");

    if (!subUnits.isEmpty()) {
        buffer.append("<ul class='mvert0 nobullet' id=\"").append("aa").append(parentUnit.getExternalId())
                .append((parentUnitParent != null) ? parentUnitParent.getExternalId() : "").append("\" ")
                .append("style='display:" + (getExpanded() != null && Boolean.valueOf(getExpanded()) ? "block" : "none"))
                .append("'>\r\n");

        Collections.sort(subUnits, Unit.COMPARATOR_BY_NAME_AND_ID);
    }

    for (Unit subUnit : subUnits) {
        getSubUnitsList(subUnit, parentUnit, buffer, currentDate, paramName, path);
    }

    if (!subUnits.isEmpty()) {
        buffer.append("</ul>");
    }
}
 
Example #15
Source File: AccountingEventPaymentCode.java    From fenixedu-academic with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void reuse(final YearMonthDay startDate, final YearMonthDay endDate, final Money minAmount, final Money maxAmount,
        final Event event) {

    reuseCode();
    update(startDate, endDate, minAmount, maxAmount);
    super.setAccountingEvent(event);
}
 
Example #16
Source File: AdministrativeOfficeFeePR.java    From fenixedu-academic with GNU Lesser General Public License v3.0 5 votes vote down vote up
public AdministrativeOfficeFeePR(DateTime startDate, DateTime endDate, ServiceAgreementTemplate serviceAgreementTemplate,
        Money fixedAmount, Money fixedAmountPenalty, YearMonthDay whenToApplyFixedAmountPenalty) {
    this();
    init(EntryType.ADMINISTRATIVE_OFFICE_FEE, EventType.ADMINISTRATIVE_OFFICE_FEE, startDate, endDate,
            serviceAgreementTemplate, fixedAmount, fixedAmountPenalty, whenToApplyFixedAmountPenalty);

}
 
Example #17
Source File: StudentCurricularPlan.java    From fenixedu-academic with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void init(Registration registration, DegreeCurricularPlan degreeCurricularPlan, YearMonthDay startDate) {

        checkParameters(registration, degreeCurricularPlan, startDate);

        setDegreeCurricularPlan(degreeCurricularPlan);
        setRegistration(registration);
        setStartDateYearMonthDay(startDate);
    }
 
Example #18
Source File: ScientificCouncilUnit.java    From fenixedu-academic with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static ScientificCouncilUnit createScientificCouncilUnit(LocalizedString name, String unitNameCard,
        Integer costCenterCode, String acronym, YearMonthDay beginDate, YearMonthDay endDate, Unit parentUnit,
        AccountabilityType accountabilityType, String webAddress, UnitClassification classification,
        Boolean canBeResponsibleOfSpaces, Space campus) {
    ScientificCouncilUnit scu = new ScientificCouncilUnit();
    scu.init(name, unitNameCard, costCenterCode, acronym, beginDate, endDate, webAddress, classification, null,
            canBeResponsibleOfSpaces, campus);
    scu.addParentUnit(parentUnit, accountabilityType);
    return scu;
}
 
Example #19
Source File: DegreeCurricularPlan.java    From fenixedu-academic with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Deprecated
public void setEndDate(java.util.Date date) {
    if (date == null) {
        setEndDateYearMonthDay(null);
    } else {
        setEndDateYearMonthDay(org.joda.time.YearMonthDay.fromDateFields(date));
    }
}
 
Example #20
Source File: InfoLessonInstanceAggregation.java    From fenixedu-academic with GNU Lesser General Public License v3.0 5 votes vote down vote up
public InfoLessonInstanceAggregation(final Shift shift, final Lesson lesson, final YearMonthDay yearMonthDay) {
    this.shift = shift;
    this.weekDay = yearMonthDay.toDateMidnight().getDayOfWeek();
    this.begin = lesson.getBeginHourMinuteSecond();
    this.end = lesson.getEndHourMinuteSecond();
    this.allocatableSpace = lesson.getSala();
}
 
Example #21
Source File: Lesson.java    From fenixedu-academic with GNU Lesser General Public License v3.0 5 votes vote down vote up
private YearMonthDay getLessonEndDay() {
    if (!wasFinished()) {
        YearMonthDay periodEnd = getPeriod().getLastOccupationPeriodOfNestedPeriods().getEndYearMonthDay();
        return getValidEndDate(periodEnd);
    }
    return null;
}
 
Example #22
Source File: EventSpaceOccupation.java    From fenixedu-academic with GNU Lesser General Public License v3.0 5 votes vote down vote up
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;
    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;
}
 
Example #23
Source File: ExecutionYear.java    From fenixedu-academic with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static ExecutionYear readBy(final YearMonthDay begin, YearMonthDay end) {
    for (final ExecutionYear executionYear : Bennu.getInstance().getExecutionYearsSet()) {
        if (executionYear.getBeginDateYearMonthDay().isEqual(begin) && executionYear.getEndDateYearMonthDay().isEqual(end)) {
            return executionYear;
        }
    }
    return null;
}
 
Example #24
Source File: Registration.java    From fenixedu-academic with GNU Lesser General Public License v3.0 5 votes vote down vote up
final public StudentCurricularPlan getStudentCurricularPlan(final YearMonthDay date) {
    StudentCurricularPlan result = null;
    for (final StudentCurricularPlan studentCurricularPlan : getStudentCurricularPlansSet()) {
        final YearMonthDay startDate = studentCurricularPlan.getStartDateYearMonthDay();
        if (!startDate.isAfter(date) && (result == null || startDate.isAfter(result.getStartDateYearMonthDay()))) {
            result = studentCurricularPlan;
        }
    }
    return result;
}
 
Example #25
Source File: DeleteLessonInstance.java    From fenixedu-academic with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Atomic
public static void run(Lesson lesson, YearMonthDay day) {
    check(RolePredicates.RESOURCE_ALLOCATION_MANAGER_PREDICATE);
    if (lesson != null && day != null) {
        lesson.deleteLessonInstanceIn(day);
    }
}
 
Example #26
Source File: Summary.java    From fenixedu-academic with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void setSummaryDateYearMonthDay(YearMonthDay summaryDateYearMonthDay) {
    if (summaryDateYearMonthDay == null) {
        throw new DomainException("error.summary.no.date");
    }
    super.setSummaryDateYearMonthDay(summaryDateYearMonthDay);
}
 
Example #27
Source File: WrittenEvaluation.java    From fenixedu-academic with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Deprecated
public void setEnrollmentBeginDayDate(java.util.Date date) {
    if (date == null) {
        setEnrollmentBeginDayDateYearMonthDay(null);
    } else {
        setEnrollmentBeginDayDateYearMonthDay(org.joda.time.YearMonthDay.fromDateFields(date));
    }
}
 
Example #28
Source File: Enrolment.java    From fenixedu-academic with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public YearMonthDay calculateConclusionDate() {
    if (!isApproved()) {
        throw new DomainException("error.Enrolment.not.approved");
    }
    return EvaluationConfiguration.getInstance().getEnrolmentEvaluationForConclusionDate(this)
            .map(EnrolmentEvaluation::getExamDateYearMonthDay).orElse(null);
}
 
Example #29
Source File: InstallmentForFirstTimeStudents.java    From fenixedu-academic with GNU Lesser General Public License v3.0 5 votes vote down vote up
public InstallmentForFirstTimeStudents(final PaymentPlan paymentPlan, final Money amount, final YearMonthDay startDate,
        final YearMonthDay endDate, final BigDecimal penaltyPercentage, final Integer maxMonthsToApplyPenalty,
        final Integer numberOfDaysToStartApplyingPenalty) {
    this();
    init(paymentPlan, amount, startDate, endDate, penaltyPercentage, maxMonthsToApplyPenalty,
            numberOfDaysToStartApplyingPenalty);
}
 
Example #30
Source File: FiliationForm.java    From fenixedu-academic with GNU Lesser General Public License v3.0 5 votes vote down vote up
private FiliationForm(YearMonthDay dateOfBirth, String districtOfBirth, String districtSubdivisionOfBirth, String fatherName,
        String motherName, Country nationality, String parishOfBirth, Country countryOfBirth) {
    this();
    this.dateOfBirth = dateOfBirth;
    this.districtOfBirth = districtOfBirth;
    this.districtSubdivisionOfBirth = districtSubdivisionOfBirth;
    this.fatherName = fatherName;
    this.motherName = motherName;
    setNationality(nationality);
    this.parishOfBirth = parishOfBirth;
    setCountryOfBirth(countryOfBirth);
}