Example usage for org.joda.time Interval Interval

List of usage examples for org.joda.time Interval Interval

Introduction

In this page you can find the example usage for org.joda.time Interval Interval.

Prototype

public Interval(Object interval, Chronology chronology) 

Source Link

Document

Constructs a time interval by converting or copying from another object, overriding the chronology.

Usage

From source file:net.sourceforge.fenixedu.domain.reports.TeacherCreditsReportFile.java

License:Open Source License

private int getDaysIn(Contract contract, ExecutionSemester executionSemester) {
    YearMonthDay begin = contract.getBeginDate().isBefore(executionSemester.getBeginDateYearMonthDay())
            ? executionSemester.getBeginDateYearMonthDay()
            : contract.getBeginDate();//from www .  j  a va2  s. c  o m
    YearMonthDay end = contract.getEndDate() == null
            || contract.getEndDate().isAfter(executionSemester.getEndDateYearMonthDay())
                    ? executionSemester.getEndDateYearMonthDay()
                    : contract.getEndDate();
    return new Interval(begin.toLocalDate().toDateTimeAtStartOfDay(),
            end.toLocalDate().toDateTimeAtStartOfDay()).toPeriod(PeriodType.days()).getDays() + 1;
}

From source file:net.sourceforge.fenixedu.domain.space.EventSpaceOccupation.java

License:Open Source License

public List<Interval> getEventSpaceOccupationIntervals(DateTime start, DateTime end) {
    final Interval i = new Interval(start, end);
    final List<Interval> intervals = getEventSpaceOccupationIntervals(start.toYearMonthDay(),
            end.toYearMonthDay());/*from   ww w  .jav a 2  s . c o m*/
    for (final Iterator<Interval> iterator = intervals.iterator(); iterator.hasNext();) {
        final Interval interval = iterator.next();
        if (!interval.overlaps(i)) {
            iterator.remove();
        }
    }
    return intervals;
}

From source file:net.sourceforge.fenixedu.domain.space.EventSpaceOccupation.java

License:Open Source License

protected static Interval createNewInterval(YearMonthDay begin, YearMonthDay end, HourMinuteSecond beginTime,
        HourMinuteSecond endTime) {//  w  w  w  .ja  v a 2  s .  c o  m
    return new Interval(begin.toDateTime(new TimeOfDay(beginTime.getHour(), beginTime.getMinuteOfHour(), 0, 0)),
            end.toDateTime(new TimeOfDay(endTime.getHour(), endTime.getMinuteOfHour(), 0, 0)));
}

From source file:net.sourceforge.fenixedu.domain.space.LessonInstanceSpaceOccupation.java

License:Open Source License

public void edit(LessonInstance lessonInstance) {
    check(this, SpacePredicates.checkPermissionsToManageLessonInstanceSpaceOccupationsWithTeacherCheck);

    if (getLessonInstancesSet().contains(lessonInstance)) {
        removeLessonInstances(lessonInstance);
    }/*  ww  w.ja va 2 s  . c om*/

    Space space = getSpace();
    //final ExecutionCourse executionCourse = lessonInstance.getLesson().getExecutionCourse();
    if (/*!space.isOccupiedByExecutionCourse(executionCourse, lessonInstance.getBeginDateTime(),
            lessonInstance.getEndDateTime())
            &&*//*!space.isFree(lessonInstance.getDay(), lessonInstance.getDay(), lessonInstance.getStartTime(),
                 lessonInstance.getEndTime(), lessonInstance.getDayOfweek(), null, null, null)*/
    !space.isFree(Lists.newArrayList(new Interval[] {
            new Interval(lessonInstance.getBeginDateTime(), lessonInstance.getEndDateTime()) }))) {

        throw new DomainException("error.LessonInstanceSpaceOccupation.room.is.not.free", space.getName(),
                lessonInstance.getDay().toString("dd-MM-yy"));
    }

    addLessonInstances(lessonInstance);
}

From source file:net.sourceforge.fenixedu.domain.space.LessonInstanceSpaceOccupation.java

License:Open Source License

@Override
public List<Interval> getEventSpaceOccupationIntervals(YearMonthDay startDateToSearch,
        YearMonthDay endDateToSearch) {/*  w  w  w.  j a  v a 2  s.com*/

    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;
}

From source file:net.sourceforge.fenixedu.domain.student.curriculum.ExtraCurricularActivity.java

License:Open Source License

public ExtraCurricularActivity(Student student, ExtraCurricularActivityType type, Partial start, Partial end) {
    this(student, type, new Interval(start.toDateTime(new DateTime(0)), end.toDateTime(new DateTime(0))));
}

From source file:net.sourceforge.fenixedu.domain.student.curriculum.ExtraCurricularActivity.java

License:Open Source License

public void setStart(Partial start) {
    setActivityInterval(new Interval(start.toDateTime(new DateTime(0)), getActivityInterval().getEnd()));
}

From source file:net.sourceforge.fenixedu.domain.student.curriculum.ExtraCurricularActivity.java

License:Open Source License

public void setEnd(Partial end) {
    setActivityInterval(new Interval(getActivityInterval().getStart(), end.toDateTime(new DateTime(0))));
}

From source file:net.sourceforge.fenixedu.domain.student.Delegate.java

License:Open Source License

public boolean isActiveForFirstExecutionYear(final ExecutionYear executionYear) {
    if (getDelegateFunction() != null && getDelegateFunction().getBeginDate() != null) {
        Interval interval = new Interval(getDelegateFunction().getBeginDate().toDateTimeAtMidnight(),
                getDelegateFunction().getEndDate().toDateTimeAtMidnight().plusDays(1));
        return executionYear.overlapsInterval(interval);
    }//  w  w  w . j  a  v  a  2s.c  o m
    return false;
}

From source file:net.sourceforge.fenixedu.domain.student.WeeklyWorkLoad.java

License:Open Source License

public Interval getInterval() {
    final DateTime beginningOfSemester = new DateTime(getAttends().getBegginingOfLessonPeriod());
    final DateTime firstMonday = beginningOfSemester.withField(DateTimeFieldType.dayOfWeek(), 1);
    final DateTime start = firstMonday.withFieldAdded(DurationFieldType.weeks(), getWeekOffset().intValue());
    final DateTime end = start.plusWeeks(1);
    return new Interval(start, end);
}