List of usage examples for org.joda.time TimeOfDay TimeOfDay
public TimeOfDay(int hourOfDay, int minuteOfHour, int secondOfMinute)
ISOChronology
in the default zone. From source file:com.moss.joda.swing.JodaOptionPane.java
License:Open Source License
private static TimeOfDay parseTime(String text) { if (text == null || text.trim().length() == 0) { return null; } else {// www. jav a2s.c o m DateTime paddedTime = null; for (DateTimeFormatter format : timeFormats) { try { paddedTime = format.parseDateTime(text); } catch (IllegalArgumentException e) { // just means the text is no good. } } if (paddedTime == null) throw new RuntimeException("Unparsable time: " + text); return new TimeOfDay(paddedTime.getHourOfDay(), paddedTime.getMinuteOfHour(), paddedTime.getSecondOfMinute()); } }
From source file:net.sourceforge.fenixedu.domain.space.LessonInstanceSpaceOccupation.java
License:Open Source License
@Override public List<Interval> getEventSpaceOccupationIntervals(YearMonthDay startDateToSearch, YearMonthDay endDateToSearch) {//from w ww .ja v a 2 s . co m 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:pt.ist.fenixedu.integration.api.FenixAPIv1.java
License:Open Source License
/** * Returns summaries for course by id//from w w w .j a va 2s. c o m * * @param oid * course id * @return */ @GET @Produces(JSON_UTF8) @Path("courses/{id}/summaries") @OAuthEndpoint(PERSONAL_SCOPE) public List<FenixLessonSummary> summariesCoursesByOid(@PathParam("id") String oid) { final ExecutionCourse executionCourse = getDomainObject(oid, ExecutionCourse.class); List<FenixLessonSummary> summaries = new ArrayList<>(); for (Shift shift : executionCourse.getAssociatedShifts()) { for (Lesson lesson : shift.getAssociatedLessonsSet()) { lesson.getAllLessonDates().stream().sorted().map(ld -> { LessonInstance lessonInstance = lesson.getLessonInstanceFor(ld); HourMinuteSecond time = lesson.getBeginHourMinuteSecond(); TimeOfDay lessonTime = new TimeOfDay(time.getHour(), time.getMinuteOfHour(), time.getSecondOfMinute()); return new FenixLessonSummary(shift, ld.toDateTime(lessonTime), lesson.getSala(), lessonInstance); }).forEach(summaries::add); } } return summaries; }