org.joda.time.YearMonthDay#toDateTime ( )源码实例Demo

下面列出了org.joda.time.YearMonthDay#toDateTime ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

@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;
}
 
源代码2 项目: fenixedu-academic   文件: EventSpaceOccupation.java
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;
}
 
源代码3 项目: fenixedu-academic   文件: EventSpaceOccupation.java
protected static Interval createNewInterval(YearMonthDay begin, YearMonthDay end, HourMinuteSecond beginTime,
        HourMinuteSecond endTime) {
    return new Interval(begin.toDateTime(new TimeOfDay(beginTime.getHour(), beginTime.getMinuteOfHour(), 0, 0)),
            end.toDateTime(new TimeOfDay(endTime.getHour(), endTime.getMinuteOfHour(), 0, 0)));
}