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

The following examples show how to use org.joda.time.YearMonthDay#toDateTimeAtMidnight() . 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: 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 2
Source File: AcademicCalendarsManagementDA.java    From fenixedu-academic with GNU Lesser General Public License v3.0 5 votes vote down vote up
private List<GanttDiagramEvent> generateEntriesTree(HttpServletRequest request, AcademicCalendarRootEntry academicCalendar,
        YearMonthDay begin, YearMonthDay end) {

    DateTime beginDateTime = begin.toDateTimeAtMidnight();
    DateTime endDateTime = end.toDateTimeAtMidnight();

    List<GanttDiagramEvent> result = new ArrayList<GanttDiagramEvent>();
    for (AcademicCalendarEntry entry : academicCalendar.getChildEntriesWithTemplateEntriesOrderByDate(beginDateTime,
            endDateTime)) {
        getSubEntriesTree(entry, result, beginDateTime, endDateTime);
    }
    return result;
}
 
Example 3
Source File: GanttDiagram.java    From fenixedu-academic with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void calculateFirstAndLastInstantInMonthlyMode(YearMonthDay begin) {
    if (begin == null) {
        throw new IllegalArgumentException();
    }
    DateTime beginDateTime = begin.toDateTimeAtMidnight();
    beginDateTime = (beginDateTime.getDayOfMonth() != 1) ? beginDateTime.withDayOfMonth(1) : beginDateTime;
    setFirstInstant(beginDateTime);
    setLastInstant(beginDateTime.plusMonths(1).minusDays(1));
}
 
Example 4
Source File: GanttDiagram.java    From fenixedu-academic with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void calculateFirstAndLastInstantInWeeklyMode(YearMonthDay begin) {
    if (begin == null) {
        throw new IllegalArgumentException();
    }
    DateTime beginDateTime = begin.toDateTimeAtMidnight();
    beginDateTime = (beginDateTime.getDayOfWeek() != 1) ? beginDateTime.withDayOfWeek(1) : beginDateTime;
    setFirstInstant(beginDateTime);
    setLastInstant(beginDateTime.plusDays(6));
}
 
Example 5
Source File: RoomSiteComponentBuilder.java    From fenixedu-academic with GNU Lesser General Public License v3.0 4 votes vote down vote up
public static InfoSiteRoomTimeTable getInfoSiteRoomTimeTable(Calendar day, Space room, ExecutionSemester executionSemester) {

        List<InfoObject> infoShowOccupations = new ArrayList<InfoObject>();

        Calendar startDay = Calendar.getInstance();
        startDay.setTimeInMillis(day.getTimeInMillis());
        startDay.add(Calendar.DATE, Calendar.MONDAY - day.get(Calendar.DAY_OF_WEEK));

        Calendar endDay = Calendar.getInstance();
        endDay.setTimeInMillis(startDay.getTimeInMillis());
        endDay.add(Calendar.DATE, 6);

        // final boolean isCurrentUserRoomManager =
        // isCurrentUserRoomManager(room);

        final YearMonthDay weekStartYearMonthDay = YearMonthDay.fromCalendarFields(startDay);
        final YearMonthDay weekEndYearMonthDay = YearMonthDay.fromCalendarFields(endDay);

        final Interval search =
                new Interval(weekStartYearMonthDay.toDateTimeAtMidnight(), weekEndYearMonthDay.toDateTimeAtMidnight());

        for (final Occupation roomOccupation : room.getOccupationSet()) {

            if (roomOccupation instanceof WrittenEvaluationSpaceOccupation) {
                Collection<WrittenEvaluation> writtenEvaluations =
                        ((WrittenEvaluationSpaceOccupation) roomOccupation).getWrittenEvaluationsSet();
                getWrittenEvaluationRoomOccupations(infoShowOccupations, weekStartYearMonthDay, weekEndYearMonthDay,
                        writtenEvaluations);
            } else if (roomOccupation instanceof LessonSpaceOccupation) {
                final Lesson lesson = ((LessonSpaceOccupation) roomOccupation).getLesson();
                getLessonOccupations(infoShowOccupations, weekStartYearMonthDay, weekEndYearMonthDay, lesson);
            } else if (roomOccupation instanceof LessonInstanceSpaceOccupation) {
                Collection<LessonInstance> lessonInstances =
                        ((LessonInstanceSpaceOccupation) roomOccupation).getLessonInstancesSet();
                getLessonInstanceOccupations(infoShowOccupations, weekStartYearMonthDay, weekEndYearMonthDay, lessonInstances);
            } else {
                for (Interval interval : roomOccupation.getIntervals()) {
                    if (search.overlaps(interval)) {
                        infoShowOccupations.add(new InfoOccupation(roomOccupation, interval));
                    }
                }
            }
        }
        InfoSiteRoomTimeTable component = new InfoSiteRoomTimeTable();

        component.setInfoShowOccupation(infoShowOccupations);
        component.setInfoRoom(InfoRoom.newInfoFromDomain(room));

        return component;
    }
 
Example 6
Source File: DiaSemana.java    From fenixedu-academic with GNU Lesser General Public License v3.0 4 votes vote down vote up
public static int getDiaSemana(YearMonthDay date) {
    DateTime dateTime = date.toDateTimeAtMidnight();
    return dateTime.getDayOfWeek() == 7 ? 1 : dateTime.getDayOfWeek() + 1;
}
 
Example 7
Source File: RegistrationState.java    From fenixedu-academic with GNU Lesser General Public License v3.0 4 votes vote down vote up
public void setStateDate(YearMonthDay yearMonthDay) {
    super.setStateDate(yearMonthDay.toDateTimeAtMidnight());
}