Example usage for org.joda.time LocalDate isBefore

List of usage examples for org.joda.time LocalDate isBefore

Introduction

In this page you can find the example usage for org.joda.time LocalDate isBefore.

Prototype

public boolean isBefore(ReadablePartial partial) 

Source Link

Document

Is this partial earlier than the specified partial.

Usage

From source file:org.estatio.dom.lease.LeaseTerm.java

License:Apache License

@Override
public String validateChangeDates(final LocalDate newStartDate, final LocalDate newEndDate) {
    String changeDatesReasonIfAny = getChangeDates().validateChangeDates(newStartDate, newEndDate);
    if (changeDatesReasonIfAny != null) {
        return changeDatesReasonIfAny;
    }// w w w . j  a v a2 s.co  m
    if (getPrevious() != null && newStartDate.isBefore(getPrevious().getStartDate())) {
        return "New start date can't be before start date of previous term";
    }
    if (getNext() != null && ObjectUtils.notEqual(newEndDate, getEndDate())) {
        return "The end date of this term is set by the start date of the next term";
    }
    return null;
}

From source file:org.estatio.dom.lease.LeaseTerm.java

License:Apache License

public String validateCreateNext(final LocalDate nextStartDate, final LocalDate nextEndDate) {
    return nextStartDate.isBefore(getStartDate()) ? "Cannot start before this start date" : null;
}

From source file:org.estatio.dom.utils.CalendarUtils.java

License:Apache License

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()));
    }/*from   w w w.  j  a  v  a 2s.co  m*/
    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;
}

From source file:org.estatio.dscm.dom.asset.Asset.java

License:Apache License

public String validateChangeDates(final LocalDate startDate, final LocalDate expiryDate) {
    if (expiryDate != null && expiryDate.isBefore(startDate)) {
        return "Exipry date cannot be before start date";
    }//from w  w w. j ava  2  s . c o  m
    return null;
}

From source file:org.estatio.dscm.dom.asset.Assets.java

License:Apache License

public String validateNewAsset(final Blob file, final Publisher publisher, final DisplayGroup displayGroup,
        final LocalDate startDate, final LocalDate expiryDate, final BigDecimal duration) {
    if (expiryDate != null && expiryDate.isBefore(startDate)) {
        return "Exipry date cannot be before start date";
    }//w ww . j a va 2s . c  om
    if (findAssetByName(file.getName()) != null) {
        return "A file with this name is already uploaded.";
    }
    return null;
}

From source file:org.fenixedu.academic.task.CronSeniorStatuteGrantor.java

License:Open Source License

protected ExecutionYear specialSeasonEnrolmentPeriodOpeningSoonForThisYear(Integer howSoon) {
    Set<EnrolmentPeriod> enrolmentPeriods = Bennu.getInstance().getEnrolmentPeriodsSet();
    Map<DegreeType, ExecutionSemester> fallTermEnrolmentPeriods = new HashMap<DegreeType, ExecutionSemester>();
    Map<DegreeType, ExecutionSemester> springTermEnrolmentPeriods = new HashMap<DegreeType, ExecutionSemester>();
    Map<DegreeType, ExecutionSemester> switcherTermEnrolmentPeriods = null;

    for (EnrolmentPeriod enrolmentPeriod : enrolmentPeriods) {
        if (!(enrolmentPeriod instanceof EnrolmentPeriodInSpecialSeasonEvaluations)) {
            continue;
        }//from  ww w .j  av a 2  s.  c o m
        LocalDate statuteGrantorStartDate = new LocalDate(enrolmentPeriod.getStartDateDateTime().toLocalDate());
        statuteGrantorStartDate = statuteGrantorStartDate.minusWeeks(howSoon);
        LocalDate statuteGrantorStopDate = new LocalDate(enrolmentPeriod.getEndDateDateTime().toLocalDate());
        statuteGrantorStopDate = statuteGrantorStopDate.plusDays(1); //inc 1 so that today is compared as before or equal to enrolmentPeriod end date
        LocalDate today = new LocalDate();
        if (today.isAfter(statuteGrantorStartDate) && today.isBefore(statuteGrantorStopDate)) {

            if (enrolmentPeriod.getExecutionPeriod().isFirstOfYear()) {
                switcherTermEnrolmentPeriods = fallTermEnrolmentPeriods;
            } else {
                switcherTermEnrolmentPeriods = springTermEnrolmentPeriods;
            }

            if (enrolmentPeriod.getDegree().getDegreeType() == DegreeType.BOLONHA_DEGREE) {
                if (switcherTermEnrolmentPeriods.get(DegreeType.BOLONHA_DEGREE) == null) {
                    switcherTermEnrolmentPeriods.put(DegreeType.BOLONHA_DEGREE,
                            enrolmentPeriod.getExecutionPeriod());
                }
            }

            if (enrolmentPeriod.getDegree().getDegreeType() == DegreeType.BOLONHA_MASTER_DEGREE) {
                if (switcherTermEnrolmentPeriods.get(DegreeType.BOLONHA_MASTER_DEGREE) == null) {
                    switcherTermEnrolmentPeriods.put(DegreeType.BOLONHA_MASTER_DEGREE,
                            enrolmentPeriod.getExecutionPeriod());
                }
            }

            if (enrolmentPeriod.getDegree().getDegreeType() == DegreeType.BOLONHA_INTEGRATED_MASTER_DEGREE) {
                if (switcherTermEnrolmentPeriods.get(DegreeType.BOLONHA_INTEGRATED_MASTER_DEGREE) == null) {
                    switcherTermEnrolmentPeriods.put(DegreeType.BOLONHA_INTEGRATED_MASTER_DEGREE,
                            enrolmentPeriod.getExecutionPeriod());
                }
            }
        }
    }

    if (fallTermEnrolmentPeriods.get(DegreeType.BOLONHA_DEGREE) == null) {
        return null;
    }
    if (fallTermEnrolmentPeriods.get(DegreeType.BOLONHA_MASTER_DEGREE) == null) {
        return null;
    }
    if (fallTermEnrolmentPeriods.get(DegreeType.BOLONHA_INTEGRATED_MASTER_DEGREE) == null) {
        return null;
    }

    if (springTermEnrolmentPeriods.get(DegreeType.BOLONHA_DEGREE) == null) {
        return null;
    }
    if (springTermEnrolmentPeriods.get(DegreeType.BOLONHA_MASTER_DEGREE) == null) {
        return null;
    }
    if (springTermEnrolmentPeriods.get(DegreeType.BOLONHA_INTEGRATED_MASTER_DEGREE) == null) {
        return null;
    }

    if (!(fallTermEnrolmentPeriods.get(DegreeType.BOLONHA_DEGREE)
            .getExecutionYear() == springTermEnrolmentPeriods.get(DegreeType.BOLONHA_DEGREE)
                    .getExecutionYear())) {
        return null;
    }

    if (!(fallTermEnrolmentPeriods.get(DegreeType.BOLONHA_MASTER_DEGREE)
            .getExecutionYear() == springTermEnrolmentPeriods.get(DegreeType.BOLONHA_MASTER_DEGREE)
                    .getExecutionYear())) {
        return null;
    }

    if (!(fallTermEnrolmentPeriods.get(DegreeType.BOLONHA_INTEGRATED_MASTER_DEGREE)
            .getExecutionYear() == springTermEnrolmentPeriods.get(DegreeType.BOLONHA_INTEGRATED_MASTER_DEGREE)
                    .getExecutionYear())) {
        return null;
    }

    if (!(fallTermEnrolmentPeriods.get(DegreeType.BOLONHA_DEGREE) == fallTermEnrolmentPeriods
            .get(DegreeType.BOLONHA_MASTER_DEGREE))) {
        return null;
    }

    if (!(fallTermEnrolmentPeriods.get(DegreeType.BOLONHA_DEGREE) == fallTermEnrolmentPeriods
            .get(DegreeType.BOLONHA_INTEGRATED_MASTER_DEGREE))) {
        return null;
    }

    return fallTermEnrolmentPeriods.get(DegreeType.BOLONHA_DEGREE).getExecutionYear();
}

From source file:org.fenixedu.academic.ui.spring.controller.AccountingReportController.java

License:Open Source License

@RequestMapping(method = RequestMethod.GET, value = "transaction-report/generate")
public String report(@RequestParam @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate start,
        @RequestParam @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate end, RedirectAttributes attrs,
        HttpServletResponse response) {//from  www.  jav  a 2s.c  o m

    if (end.isBefore(start)) {
        attrs.addFlashAttribute("message",
                BundleUtil.getString(Bundle.ACCOUNTING, "error.transaction.report.wrong.dates",
                        start.toString("dd/MM/yyyy"), end.toString("dd/MM/yyyy")));
        return "redirect:/accounting-management/reports";
    }

    final String filename = BundleUtil.getString(Bundle.ACCOUNTING, "label.transaction.report.filename",
            start.toString("dd_MM_yyyy"), end.toString("dd_MM_yyyy"),
            new DateTime().toString("dd_MM_yyyy-HH_mm_ss"));

    try {
        final Spreadsheet report = accountingReportService.report(start, end);
        response.setHeader("Content-Disposition", String.format("attachment; filename=\"%s.xlsx\"", filename));
        response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
        report.exportToXLSXSheet(response.getOutputStream());
        response.flushBuffer();
        return null;
    } catch (IOException e) {
        throw new Error(e);
    }
}

From source file:org.fenixedu.treasury.domain.document.DebitEntry.java

License:Open Source License

private boolean toCalculateInterests(final LocalDate whenToCalculate) {
    return !whenToCalculate.isBefore(getDueDate().plusDays(getInterestRate().getNumberOfDaysAfterDueDate()));
}

From source file:org.goobi.production.model.bibliography.course.Block.java

License:Open Source License

/**
 * The function isMatch() returns whether a given LocalDate comes within the
 * limits of this block. Defaults to false if either the argument or one of
 * the fields to compare against is null.
 *
 * @param date/*from  www .j a  v a2 s . c om*/
 *            a LocalDate to examine
 * @return whether the date is within the limits of this block
 */
public boolean isMatch(LocalDate date) {
    try {
        return !date.isBefore(firstAppearance) && !date.isAfter(lastAppearance);
    } catch (IllegalArgumentException e) {
        return false;
    }
}

From source file:org.goobi.production.model.bibliography.course.Course.java

License:Open Source License

/**
 * The function getFirstAppearance() returns the date the regularity of this
 * course of appearance starts with./*from  w w  w. ja v  a  2 s . c  o  m*/
 *
 * @return the date of first appearance
 */
public LocalDate getFirstAppearance() {
    if (super.isEmpty()) {
        return null;
    }
    LocalDate result = super.get(0).getFirstAppearance();
    for (int index = 1; index < super.size(); index++) {
        LocalDate firstAppearance = super.get(index).getFirstAppearance();
        if (firstAppearance.isBefore(result)) {
            result = firstAppearance;
        }
    }
    return result;
}