Java Code Examples for org.joda.time.LocalDate#compareTo()

The following examples show how to use org.joda.time.LocalDate#compareTo() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CalendarUtils.java    From estatio with Apache License 2.0 6 votes vote down vote up
public static Interval currentInterval(
        final LocalDate date,
        final String rrule,
        final LocalDate startDate) {
    if (date == null || startDate == null || rrule == null) {
        return null;
    }
    try {
        LocalDate thisDate = startDate;
        final LocalDateIterator iter =
                LocalDateIteratorFactory.createLocalDateIterator(rrule, thisDate, true);
        while (iter.hasNext()) {
            LocalDate nextDate = iter.next();
            if (nextDate.compareTo(date) > 0) {
                return new Interval(
                        thisDate.toInterval().getStartMillis(),
                        nextDate.toInterval().getStartMillis());
            }
            thisDate = nextDate;
        }
    } catch (final ParseException ex) {
        throw new IncodeApplicationException("Unable to parse rrule >>" + rrule + "<<", ex);
    }
    return null;
}
 
Example 2
Source File: CalendarUtils.java    From estatio with Apache License 2.0 6 votes vote down vote up
public static List<Interval> intervalsInRange(
        final LocalDate startDate,
        final LocalDate endDate,
        final String rrule) {
    if (startDate.compareTo(endDate) > 0) {
        throw new IllegalArgumentException(
                String.format("Start date %s is after end date %s", startDate.toString(), endDate.toString()));
    }
    List<Interval> intervals = Lists.newArrayList();
    LocalDate start = startDate;
    Interval interval = null;
    do {
        interval = intervalContaining(start, rrule);
        if (interval != null) {
            intervals.add(interval);
            start = interval.getEnd().toLocalDate();
        }
    } while (interval != null && start.isBefore(endDate));
    return intervals;
}
 
Example 3
Source File: CreatePastDiplomaRequest.java    From fenixedu-academic with GNU Lesser General Public License v3.0 5 votes vote down vote up
private static void createSituations(PastDiplomaRequest request, DocumentRequestCreateBean bean) {
    if (!bean.getRegistration().isRegistrationConclusionProcessed()) {
        throw new DomainException("DiplomaRequest.diploma.cannot.be.concluded");
    }

    LocalDate latestDate = bean.getPastRequestDate();
    if (bean.getPastPaymentDate() == null) {
        bean.setPastPaymentDate(latestDate);
    } else {
        latestDate = (latestDate.compareTo(bean.getPastPaymentDate()) < 0) ? bean.getPastPaymentDate() : latestDate;
    }
    if (bean.getPastEmissionDate() == null) {
        bean.setPastEmissionDate(latestDate);
    } else {
        latestDate = (latestDate.compareTo(bean.getPastEmissionDate()) < 0) ? bean.getPastEmissionDate() : latestDate;
    }
    if (bean.getPastDispatchDate() == null) {
        bean.setPastDispatchDate(latestDate);
    }

    createPaymentSituation(request, bean);
    process(request, bean.getPastRequestDate());
    request.setNumberOfPages(1);
    send(request, bean.getPastRequestDate());
    receive(request, bean.getPastRequestDate());
    conclude(request, bean.getPastEmissionDate());
    deliver(request, bean.getPastDispatchDate());
}
 
Example 4
Source File: LeaseTermForIndexable.java    From estatio with Apache License 2.0 5 votes vote down vote up
@Override
@Programmatic
public BigDecimal valueForDate(final LocalDate dueDate) {
    // use the indexed value on or after the effective date, use the base
    // otherwise
    if (getEffectiveDate() == null || dueDate.compareTo(getEffectiveDate()) >= 0) {
        return MathUtils.firstNonZero(getSettledValue(), getEffectiveIndexedValue(), getIndexedValue(), getBaseValue());
    }
    return MathUtils.firstNonZero(getBaseValue(), getSettledValue());
}
 
Example 5
Source File: FixedBreakOption.java    From estatio with Apache License 2.0 5 votes vote down vote up
public String validateUpdateReminderDate(final LocalDate reminderDate) {
    if (reminderDate == null) {
        return null;
    }
    return reminderDate.compareTo(getExerciseDate()) >= 0
            ? "Reminder must be before exercise date"
            : null;
}
 
Example 6
Source File: LeaseTermForServiceCharge.java    From estatio with Apache License 2.0 5 votes vote down vote up
@Override
@Programmatic
public BigDecimal valueForDate(final LocalDate dueDate) {
    // TODO: we might need an effective date on the Service Charge too
    LocalDate endDate = getInterval().endDateExcluding();
    if (endDate != null) {
        LocalDate effectiveDate = endDate;
        if (getEndDate() != null && effectiveDate.compareTo(dueDate) <= 0) {
            return getEffectiveValue();
        }
    }
    return MathUtils.firstNonZero(getManualServiceChargeValue(), getBudgetedValue());
}
 
Example 7
Source File: LeaseTermForTesting.java    From estatio with Apache License 2.0 5 votes vote down vote up
@Override
public BigDecimal valueForDate(LocalDate date){
    // after the end date the adjusted value is returned
    if (getEndDate() != null && date.compareTo(getEndDate()) >= 0) {
        return adjustedValue != null ? adjustedValue : value;
    }
    return value;
}
 
Example 8
Source File: InvoiceServiceMenu.java    From estatio with Apache License 2.0 4 votes vote down vote up
private String doValidateCalculateInvoicesForProperty(final LocalDate startDate, final LocalDate endDate) {
    if (endDate.compareTo(startDate) < 0) {
        return "End date is before start date";
    }
    return null;
}
 
Example 9
Source File: RollingBreakOption.java    From estatio with Apache License 2.0 4 votes vote down vote up
private static LocalDate laterOf(final LocalDate d1, final LocalDate d2) {
    return d1.compareTo(d2) < 0 ? d1 : d2;
}
 
Example 10
Source File: CalendarUtils.java    From estatio with Apache License 2.0 4 votes vote down vote up
public static boolean isBetween(final LocalDate date, final LocalDate startDate, final LocalDate endDate) {
    if (startDate != null && date.compareTo(startDate) >= 0 && (endDate == null || date.compareTo(endDate) <= 0)) {
        return true;
    }
    return false;
}