下面列出了org.joda.time.LocalDate#compareTo ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
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;
}
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;
}
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());
}
@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());
}
public String validateUpdateReminderDate(final LocalDate reminderDate) {
if (reminderDate == null) {
return null;
}
return reminderDate.compareTo(getExerciseDate()) >= 0
? "Reminder must be before exercise date"
: null;
}
@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());
}
@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;
}
private String doValidateCalculateInvoicesForProperty(final LocalDate startDate, final LocalDate endDate) {
if (endDate.compareTo(startDate) < 0) {
return "End date is before start date";
}
return null;
}
private static LocalDate laterOf(final LocalDate d1, final LocalDate d2) {
return d1.compareTo(d2) < 0 ? d1 : d2;
}
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;
}