下面列出了org.joda.time.YearMonthDay#toDateTimeAtMidnight ( ) 实例代码,或者点击链接到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;
}
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;
}
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));
}
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));
}
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;
}
public static int getDiaSemana(YearMonthDay date) {
DateTime dateTime = date.toDateTimeAtMidnight();
return dateTime.getDayOfWeek() == 7 ? 1 : dateTime.getDayOfWeek() + 1;
}
public void setStateDate(YearMonthDay yearMonthDay) {
super.setStateDate(yearMonthDay.toDateTimeAtMidnight());
}