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

The following are Jave code examples for showing how to use isBefore() 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: exam   File: CalendarController.java   Source Code and License Vote up 5 votes
/**
 * @return which one is sooner, exam period's end or week's end
 */
private static LocalDate getEndSearchDate(Exam exam, LocalDate searchDate) {
    LocalDate endOfWeek = searchDate.dayOfWeek().withMaximumValue();
    LocalDate examEnd = new LocalDate(exam.getExamActiveEndDate());
    String reservationWindow = SettingsController.getOrCreateSettings(
            "reservation_window_size", null, null).getValue();
    int windowSize = 0;
    if (reservationWindow != null) {
        windowSize = Integer.parseInt(reservationWindow);
    }
    LocalDate reservationWindowDate = LocalDate.now().plusDays(windowSize);
    LocalDate endOfSearchDate = examEnd.isBefore(reservationWindowDate) ? examEnd : reservationWindowDate;

    return endOfWeek.isBefore(endOfSearchDate) ? endOfWeek : endOfSearchDate;
}
 
Example 3
Project: exam   File: ExternalCalendarController.java   Source Code and License Vote up 5 votes
/**
 * @return which one is sooner, exam period's end or week's end
 */
private static LocalDate getEndSearchDate(String endDate, LocalDate searchDate) {
    LocalDate endOfWeek = searchDate.dayOfWeek().withMaximumValue();
    LocalDate examEnd = LocalDate.parse(endDate, ISODateTimeFormat.dateTimeParser());
    String reservationWindow = SettingsController.getOrCreateSettings(
            "reservation_window_size", null, null).getValue();
    int windowSize = 0;
    if (reservationWindow != null) {
        windowSize = Integer.parseInt(reservationWindow);
    }
    LocalDate reservationWindowDate = LocalDate.now().plusDays(windowSize);
    LocalDate endOfSearchDate = examEnd.isBefore(reservationWindowDate) ? examEnd : reservationWindowDate;

    return endOfWeek.isBefore(endOfSearchDate) ? endOfWeek : endOfSearchDate;
}
 
Example 4
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);
}