Java Code Examples for org.joda.time.YearMonthDay#getYear()

The following examples show how to use org.joda.time.YearMonthDay#getYear() . 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: ViewEventSpaceOccupationsBean.java    From fenixedu-academic with GNU Lesser General Public License v3.0 6 votes vote down vote up
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);
            }

            setDay(monday);
        }
    }
 
Example 2
Source File: PostingRulesManager.java    From fenixedu-academic with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Atomic
public static void createDEAStandaloneGratuityPostingRule(StandaloneInstallmentBean bean,
        DegreeCurricularPlan degreeCurricularPlan) {
    DegreeCurricularPlanServiceAgreementTemplate dcpSAT = degreeCurricularPlan.getServiceAgreementTemplate();
    if (dcpSAT != null) {
        YearMonthDay startDate = bean.getStartDate();

        LocalDate startLocalDate = new LocalDate(startDate.getYear(), startDate.getMonthOfYear(), startDate.getDayOfMonth());
        BigDecimal ectsForYear = bean.getEctsForYear();
        BigDecimal gratuityFactor = bean.getGratuityFactor();
        BigDecimal ectsFactor = bean.getEctsFactor();

        new StandaloneEnrolmentGratuityPR(startLocalDate.toDateTimeAtStartOfDay(), null, dcpSAT, ectsForYear, gratuityFactor,
                ectsFactor);
    } else {
        throw new DomainException("StandaloneEnrolmentGratuityPR.DegreeCurricularPlanServiceAgreementTemplate.cannot.be.null");
    }
}
 
Example 3
Source File: MonthMondayDaysProvider.java    From fenixedu-academic with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public Object provide(Object source, Object currentValue) {

    List<YearMonthDay> result = new ArrayList<YearMonthDay>();
    ViewEventSpaceOccupationsBean bean = (ViewEventSpaceOccupationsBean) source;
    Partial year = bean.getYear();
    Partial month = bean.getMonth();

    if (month != null && year != null) {

        int monthNumber = month.get(DateTimeFieldType.monthOfYear());
        int yearNumber = year.get(DateTimeFieldType.year());

        YearMonthDay firstDayOfMonth = new YearMonthDay(yearNumber, monthNumber, 1);
        YearMonthDay monday = firstDayOfMonth.toDateTimeAtMidnight().withDayOfWeek(MONDAY_IN_JODA_TIME).toYearMonthDay();

        if ((monday.getMonthOfYear() < monthNumber) || (monday.getYear() < yearNumber)) {
            monday = monday.plusDays(Lesson.NUMBER_OF_DAYS_IN_WEEK);
        }

        while (monday.getMonthOfYear() == monthNumber) {
            result.add(monday);
            monday = monday.plusDays(Lesson.NUMBER_OF_DAYS_IN_WEEK);
        }
    }

    return result;
}
 
Example 4
Source File: WrittenEvaluation.java    From fenixedu-academic with GNU Lesser General Public License v3.0 5 votes vote down vote up
public DateTime getBeginningDateTime() {
    HourMinuteSecond begin = this.getBeginningDateHourMinuteSecond();
    YearMonthDay yearMonthDay = this.getDayDateYearMonthDay();
    return new DateTime(yearMonthDay.getYear(), yearMonthDay.getMonthOfYear(), yearMonthDay.getDayOfMonth(), begin.getHour(),
            begin.getMinuteOfHour(), 0, 0);

}
 
Example 5
Source File: WrittenEvaluation.java    From fenixedu-academic with GNU Lesser General Public License v3.0 5 votes vote down vote up
public DateTime getEndDateTime() {
    HourMinuteSecond end = this.getEndDateHourMinuteSecond();
    YearMonthDay yearMonthDay = this.getDayDateYearMonthDay();
    return new DateTime(yearMonthDay.getYear(), yearMonthDay.getMonthOfYear(), yearMonthDay.getDayOfMonth(), end.getHour(),
            end.getMinuteOfHour(), 0, 0);

}
 
Example 6
Source File: WrittenEvaluation.java    From fenixedu-academic with GNU Lesser General Public License v3.0 5 votes vote down vote up
private DateTime toDateTime(final YearMonthDay yearMonthDay, final HourMinuteSecond hourMinuteSecond) {
    if (yearMonthDay == null || hourMinuteSecond == null) {
        return null;
    }
    return new DateTime(yearMonthDay.getYear(), yearMonthDay.getMonthOfYear(), yearMonthDay.getDayOfMonth(),
            hourMinuteSecond.getHour(), hourMinuteSecond.getMinuteOfHour(), hourMinuteSecond.getSecondOfMinute(), 0);
}
 
Example 7
Source File: LessonInstance.java    From fenixedu-academic with GNU Lesser General Public License v3.0 5 votes vote down vote up
public LessonInstance(Lesson lesson, YearMonthDay day) {
//        check(this, ResourceAllocationRolePredicates.checkPermissionsToManageLessonInstancesWithTeacherCheck);

        super();

        if (day == null) {
            throw new DomainException("error.LessonInstance.empty.day");
        }

        if (lesson == null) {
            throw new DomainException("error.LessonInstance.empty.Lesson");
        }

        LessonInstance lessonInstance = lesson.getLessonInstanceFor(day);
        if (lessonInstance != null) {
            throw new DomainException("error.lessonInstance.already.exist");
        }

        Space room = lesson.getSala();

        HourMinuteSecond beginTime = lesson.getBeginHourMinuteSecond();
        HourMinuteSecond endTime = lesson.getEndHourMinuteSecond();
        DateTime beginDateTime =
                new DateTime(day.getYear(), day.getMonthOfYear(), day.getDayOfMonth(), beginTime.getHour(),
                        beginTime.getMinuteOfHour(), beginTime.getSecondOfMinute(), 0);
        DateTime endDateTime =
                new DateTime(day.getYear(), day.getMonthOfYear(), day.getDayOfMonth(), endTime.getHour(),
                        endTime.getMinuteOfHour(), endTime.getSecondOfMinute(), 0);

        setRootDomainObject(Bennu.getInstance());
        setBeginDateTime(beginDateTime);
        setEndDateTime(endDateTime);
        setLesson(lesson);

        lessonInstanceSpaceOccupationManagement(room);
    }
 
Example 8
Source File: CalendarEntryBean.java    From fenixedu-academic with GNU Lesser General Public License v3.0 4 votes vote down vote up
public static Partial getPartialFromYearMonthDay(YearMonthDay day) {
    return new Partial(new DateTimeFieldType[] { DateTimeFieldType.year(), DateTimeFieldType.monthOfYear() }, new int[] {
            day.getYear(), day.getMonthOfYear() });
}
 
Example 9
Source File: Lesson.java    From fenixedu-academic with GNU Lesser General Public License v3.0 4 votes vote down vote up
private static DateTime toDateTime(final YearMonthDay ymd, final HourMinuteSecond hms) {
    return new DateTime(ymd.getYear(), ymd.getMonthOfYear(), ymd.getDayOfMonth(),
            hms.getHour(), hms.getMinuteOfHour(), hms.getSecondOfMinute(), 0);
}
 
Example 10
Source File: WrittenEvaluation.java    From fenixedu-academic with GNU Lesser General Public License v3.0 4 votes vote down vote up
private DateTime convertTimes(YearMonthDay yearMonthDay, HourMinuteSecond hourMinuteSecond) {
    return new DateTime(yearMonthDay.getYear(), yearMonthDay.getMonthOfYear(), yearMonthDay.getDayOfMonth(),
            hourMinuteSecond.getHour(), hourMinuteSecond.getMinuteOfHour(), hourMinuteSecond.getSecondOfMinute(), 0);
}
 
Example 11
Source File: LessonInstance.java    From fenixedu-academic with GNU Lesser General Public License v3.0 4 votes vote down vote up
public LessonInstance(Summary summary, Lesson lesson) {
//        check(this, ResourceAllocationRolePredicates.checkPermissionsToManageLessonInstancesWithTeacherCheck);

        super();

        if (summary == null) {
            throw new DomainException("error.LessonInstance.empty.summary");
        }

        if (lesson == null) {
            throw new DomainException("error.LessonInstance.empty.lesson");
        }

        YearMonthDay day = summary.getSummaryDateYearMonthDay();

        LessonInstance lessonInstance = lesson.getLessonInstanceFor(day);
        if (lessonInstance != null) {
            throw new DomainException("error.lessonInstance.already.exist");
        }

        Space room = lesson.getSala();

        HourMinuteSecond beginTime = lesson.getBeginHourMinuteSecond();
        HourMinuteSecond endTime = lesson.getEndHourMinuteSecond();
        DateTime beginDateTime =
                new DateTime(day.getYear(), day.getMonthOfYear(), day.getDayOfMonth(), beginTime.getHour(),
                        beginTime.getMinuteOfHour(), beginTime.getSecondOfMinute(), 0);
        DateTime endDateTime =
                new DateTime(day.getYear(), day.getMonthOfYear(), day.getDayOfMonth(), endTime.getHour(),
                        endTime.getMinuteOfHour(), endTime.getSecondOfMinute(), 0);

        setRootDomainObject(Bennu.getInstance());
        setBeginDateTime(beginDateTime);
        setEndDateTime(endDateTime);

        YearMonthDay nextPossibleDay = findNextPossibleDateAfter(day, lesson);

        setLesson(lesson);

        summaryAndCourseLoadManagement(summary, lesson);
        lesson.refreshPeriodAndInstancesInSummaryCreation(nextPossibleDay);
        lessonInstanceSpaceOccupationManagement(room);
    }