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.ExecutionSemester.java

License:Open Source License

public Interval getPreviousWeek() {
    final DateMidnight thisMonday = getThisMonday();
    return thisMonday == null ? null : new Interval(thisMonday.minusWeeks(1), thisMonday);
}

From source file:net.sourceforge.fenixedu.domain.ExecutionYear.java

License:Open Source License

public boolean containsDate(final DateTime dateTime) {
    final DateMidnight begin = getBeginDateYearMonthDay().toDateMidnight();
    final DateMidnight end = getEndDateYearMonthDay().plusDays(1).toDateMidnight();
    return new Interval(begin, end).contains(dateTime);
}

From source file:net.sourceforge.fenixedu.domain.ExecutionYear.java

License:Open Source License

public boolean overlapsInterval(final Interval interval) {
    final DateMidnight begin = getBeginDateYearMonthDay().toDateMidnight();
    final DateMidnight end = getEndDateYearMonthDay().plusDays(1).toDateMidnight();
    return new Interval(begin, end).overlaps(interval);
}

From source file:net.sourceforge.fenixedu.domain.finalDegreeWork.Scheduleing.java

License:Open Source License

private Interval getInterval(final Date startDate, final Date startTime, final Date endDate,
        final Date endTime) {
    if (startDate != null && startTime != null && endDate != null && endTime != null) {
        final DateTime start = newDateTime(startDate, startTime);
        final DateTime end = newDateTime(endDate, endTime);
        if (start != null && end != null) {
            return new Interval(start, end);
        }//from  w ww.j  a v a2 s. c  o  m
    }
    return null;
}

From source file:net.sourceforge.fenixedu.domain.finalDegreeWork.Scheduleing.java

License:Open Source License

private Interval toInterval(final DateTime start, final DateTime end) {
    return start == null || end == null || !end.isAfter(start) ? null : new Interval(start, end);
}

From source file:net.sourceforge.fenixedu.domain.Lesson.java

License:Open Source License

public SortedSet<Interval> getAllLessonIntervalsWithoutInstanceDates() {
    SortedSet<Interval> dates = new TreeSet<Interval>(new Comparator<Interval>() {

        @Override//from   w  ww  . java  2 s. c  o m
        public int compare(Interval o1, Interval o2) {
            return o1.getStart().compareTo(o2.getStart());
        }

    });
    if (!wasFinished()) {
        YearMonthDay startDateToSearch = getLessonStartDay();
        YearMonthDay endDateToSearch = getLessonEndDay();
        final HourMinuteSecond b = getBeginHourMinuteSecond();
        final HourMinuteSecond e = getEndHourMinuteSecond();
        for (final YearMonthDay yearMonthDay : getAllValidLessonDatesWithoutInstancesDates(startDateToSearch,
                endDateToSearch)) {
            final DateTime start = new DateTime(yearMonthDay.getYear(), yearMonthDay.getMonthOfYear(),
                    yearMonthDay.getDayOfMonth(), b.getHour(), b.getMinuteOfHour(), b.getSecondOfMinute(), 0);
            final DateTime end = new DateTime(yearMonthDay.getYear(), yearMonthDay.getMonthOfYear(),
                    yearMonthDay.getDayOfMonth(), e.getHour(), e.getMinuteOfHour(), e.getSecondOfMinute(), 0);
            dates.add(new Interval(start, end));
        }
    }
    return dates;
}

From source file:net.sourceforge.fenixedu.domain.Lesson.java

License:Open Source License

public Set<Interval> getAllLessonIntervals() {
    Set<Interval> intervals = new HashSet<Interval>();
    for (LessonInstance instance : getLessonInstancesSet()) {
        intervals.add(new Interval(instance.getBeginDateTime(), instance.getEndDateTime()));
    }/*from w  w w. j  a v  a 2 s. c  o  m*/
    if (!wasFinished()) {
        YearMonthDay startDateToSearch = getLessonStartDay();
        YearMonthDay endDateToSearch = getLessonEndDay();
        for (YearMonthDay day : getAllValidLessonDatesWithoutInstancesDates(startDateToSearch,
                endDateToSearch)) {
            intervals.add(new Interval(
                    day.toLocalDate()
                            .toDateTime(new LocalTime(getBeginHourMinuteSecond().getHour(),
                                    getBeginHourMinuteSecond().getMinuteOfHour(),
                                    getBeginHourMinuteSecond().getSecondOfMinute())),
                    day.toLocalDate()
                            .toDateTime(new LocalTime(getEndHourMinuteSecond().getHour(),
                                    getEndHourMinuteSecond().getMinuteOfHour(),
                                    getEndHourMinuteSecond().getSecondOfMinute()))));
        }
    }
    return intervals;
}

From source file:net.sourceforge.fenixedu.domain.LessonInstance.java

License:Open Source License

public Interval getInterval() {
    return new Interval(getBeginDateTime(), getEndDateTime());
}

From source file:net.sourceforge.fenixedu.domain.mobility.outbound.OutboundMobilityCandidacyPeriod.java

License:Open Source License

public Interval getInterval() {
    return new Interval(getStart(), getEnd());
}

From source file:net.sourceforge.fenixedu.domain.OccupationPeriod.java

License:Open Source License

public Interval getIntervalWithNextPeriods() {
    return new Interval(getStartYearMonthDay().toLocalDate().toDateTimeAtStartOfDay(),
            getEndYearMonthDayWithNextPeriods().toLocalDate().toDateTimeAtStartOfDay());
}