Java Code Examples for org.joda.time.LocalDate.isAfter()

The following are Jave code examples for showing how to use isAfter() of the org.joda.time.LocalDate class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: wulkanowy   File: TimeUtils.java   Source Code and License Vote up 6 votes
public static List<String> getMondaysFromCurrentSchoolYear(String dateFormat) {
    LocalDate startDate = new LocalDate(getCurrentSchoolYear(), 9, 1);
    LocalDate endDate = new LocalDate(getCurrentSchoolYear() + 1, 8, 31);

    List<String> dateList = new ArrayList<>();

    LocalDate thisMonday = startDate.withDayOfWeek(DateTimeConstants.MONDAY);

    if (startDate.isAfter(thisMonday)) {
        startDate = thisMonday.plusWeeks(1);
    } else {
        startDate = thisMonday;
    }

    while (startDate.isBefore(endDate)) {
        dateList.add(startDate.toString(dateFormat));
        startDate = startDate.plusWeeks(1);
    }
    return dateList;
}
 
Example 2
Project: yum   File: OrdersService.java   Source Code and License Vote up 5 votes
private Boolean allowAdminAfterTodayChangeOrder(com.jrtechnologies.yum.data.entity.User sourceUser, LocalDate menuDate,
        Long userId) {
    if (userId != 0 && sourceUser.getUserRole().toString().equalsIgnoreCase("admin")
            && (menuDate.isEqual(new LocalDate()) || menuDate.isAfter(new LocalDate()))) {
        return true;
    }
    return false;
}
 
Example 3
Project: exam   File: CalendarController.java   Source Code and License Vote up 5 votes
@Restrict({@Group("ADMIN"), @Group("STUDENT")})
public Result getSlots(Long examId, Long roomId, String day, Collection<Integer> aids) {
    User user = getLoggedUser();
    Exam exam = getEnrolledExam(examId, user);
    if (exam == null) {
        return forbidden("sitnet_error_enrolment_not_found");
    }
    ExamRoom room = Ebean.find(ExamRoom.class, roomId);
    if (room == null) {
        return forbidden(String.format("No room with id: (%d)", roomId));
    }
    Collection<TimeSlot> slots = new ArrayList<>();
    if (!room.getOutOfService() && !room.getState().equals(ExamRoom.State.INACTIVE.toString()) &&
            isRoomAccessibilitySatisfied(room, aids) && exam.getDuration() != null) {
        LocalDate searchDate;
        try {
            searchDate = parseSearchDate(day, exam, room);
        } catch (NotFoundException e) {
            return notFound();
        }
        // users reservations starting from now
        List<Reservation> reservations = Ebean.find(Reservation.class)
                .fetch("enrolment.exam")
                .where()
                .eq("user", user)
                .gt("startAt", searchDate.toDate())
                .findList();
        // Resolve eligible machines based on software and accessibility requirements
        List<ExamMachine> machines = getEligibleMachines(room, aids, exam);
        LocalDate endOfSearch = getEndSearchDate(exam, searchDate);
        while (!searchDate.isAfter(endOfSearch)) {
            Set<TimeSlot> timeSlots = getExamSlots(user, room, exam, searchDate, reservations, machines);
            if (!timeSlots.isEmpty()) {
                slots.addAll(timeSlots);
            }
            searchDate = searchDate.plusDays(1);
        }
    }
    return ok(Json.toJson(slots));
}
 
Example 4
Project: exam   File: ExternalCalendarController.java   Source Code and License Vote up 5 votes
@SubjectNotPresent
public Result provideSlots(Optional<String> roomId, Optional<String> date, Optional<String> start, Optional<String> end,
                           Optional<Integer> duration) {
    if (roomId.isPresent() && date.isPresent() && start.isPresent() && end.isPresent() && duration.isPresent()) {
        ExamRoom room = Ebean.find(ExamRoom.class).where().eq("externalRef", roomId.get()).findUnique();
        if (room == null) {
            return forbidden(String.format("No room with ref: (%s)", roomId.get()));
        }
        Collection<TimeSlot> slots = new ArrayList<>();
        if (!room.getOutOfService() && !room.getState().equals(ExamRoom.State.INACTIVE.toString())) {
            LocalDate searchDate;
            try {
                searchDate = parseSearchDate(date.get(), start.get(), end.get(), room);
            } catch (NotFoundException e) {
                return notFound();
            }
            List<ExamMachine> machines = Ebean.find(ExamMachine.class)
                    .where()
                    .eq("room.id", room.getId())
                    .ne("outOfService", true)
                    .ne("archived", true)
                    .findList();
            LocalDate endOfSearch = getEndSearchDate(end.get(), searchDate);
            while (!searchDate.isAfter(endOfSearch)) {
                Set<TimeSlot> timeSlots = getExamSlots(room, duration.get(), searchDate, machines);
                if (!timeSlots.isEmpty()) {
                    slots.addAll(timeSlots);
                }
                searchDate = searchDate.plusDays(1);
            }
        }
        return ok(Json.toJson(slots));
    } else {
        return badRequest();
    }
}
 
Example 5
Project: mobile-app-dev-book   File: MonthlyFragment.java   Source Code and License Vote up 5 votes
@Override
public void onJournalUpdated(List<Trip> trips) {
    tripDays.clear();
    for (Trip t : trips) {
        LocalDate d = DateTime.parse(t.getStartDate()).toLocalDate();
        LocalDate endDate = DateTime.parse(t.getEndDate()).toLocalDate();
        while (!d.isAfter(endDate)) {
            tripDays.add(d);
            d = d.plusDays(1);
        }
    }
    monthly.invalidateDecorators();
}
 
Example 6
Project: oma-riista-android   File: DateTimeUtils.java   Source Code and License Vote up 3 votes
/**
 * Check if date is in range (inclusive)
 *
 * @param validateDate Check date
 * @param beginDate    First date in range
 * @param endDate      Last day in range
 * @return Is date in range (includes begin and end dates)
 */
static public boolean isDateInRange(LocalDate validateDate, LocalDate beginDate, LocalDate endDate) {
    if (validateDate == null || beginDate == null || endDate == null) {
        return false;
    }

    return !validateDate.isBefore(beginDate) && !validateDate.isAfter(endDate);
}