List of usage examples for org.joda.time LocalDate isAfter
public boolean isAfter(ReadablePartial partial)
From source file:org.estatio.dom.valuetypes.AbstractInterval.java
License:Apache License
/** * Does this date contain the specified time interval. * //from ww w . j av a 2s . c om * @param date * @return */ public boolean contains(final LocalDate date) { if (date == null) { return false; } if (endDate() == null) { if (startDate() == null) { return true; } if (date.isEqual(startDate()) || date.isAfter(startDate())) { return true; } return false; } return asInterval().contains(date.toInterval()); }
From source file:org.fenixedu.academic.domain.student.SeparationCyclesManagement.java
License:Open Source License
private void markOldRegistrationWithConcludedState(final StudentCurricularPlan oldStudentCurricularPlan) { if (oldStudentCurricularPlan.getRegistration().hasState(RegistrationStateType.CONCLUDED)) { return;//from w w w.j a va 2s . c om } LocalDate stateDate = new LocalDate(); if (stateDate.isAfter(getExecutionYear().getEndDateYearMonthDay())) { stateDate = getExecutionYear().getEndDateYearMonthDay().toLocalDate(); } final RegistrationState state = RegistrationState.createRegistrationState( oldStudentCurricularPlan.getRegistration(), null, stateDate.toDateTimeAtStartOfDay(), RegistrationStateType.CONCLUDED); state.setResponsiblePerson(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; }/* w w w . jav 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.treasury.domain.tariff.InterestRate.java
License:Open Source License
public InterestRateBean calculateInterest(final Map<LocalDate, BigDecimal> amountInDebtMap, final Map<LocalDate, BigDecimal> createdInterestEntries, final LocalDate dueDate, final LocalDate paymentDate) { TreeMap<LocalDate, BigDecimal> sortedMap = new TreeMap<LocalDate, BigDecimal>(); sortedMap.putAll(amountInDebtMap);//from w w w .ja v a 2s. co m if (getInterestType().isGlobalRate() && !GlobalInterestRate.findUniqueByYear(dueDate.getYear()).get().isApplyPaymentMonth()) { final LocalDate lastDayForInterestCalculation = paymentDate.withField(DateTimeFieldType.dayOfMonth(), 1) .minusDays(1); for (final LocalDate localDate : Sets.newTreeSet(sortedMap.keySet())) { if (localDate.isAfter(lastDayForInterestCalculation)) { sortedMap.remove(localDate); } } sortedMap.put(lastDayForInterestCalculation, BigDecimal.ZERO); } else { sortedMap.put(paymentDate, BigDecimal.ZERO); } sortedMap = splitDatesWithYearsSpan(sortedMap); if (getInterestType().isFixedAmount()) { return calculedForFixedAmount(); } if (getInterestType().isDaily() || getInterestType().isGlobalRate()) { return calculateDaily(createdInterestEntries, dueDate, paymentDate, sortedMap); } if (getInterestType().isMonthly()) { return calculateMonthly(createdInterestEntries, dueDate, paymentDate, sortedMap); } throw new RuntimeException("unknown interest type formula"); }
From source file:org.fenixedu.treasury.domain.tariff.Tariff.java
License:Open Source License
public LocalDate dueDate(final LocalDate requestDate) { if (getDueDateCalculationType().isFixedDate()) { return getFixedDueDate(); }//from w w w .j av a2 s . c om if (getDueDateCalculationType().isBestOfFixedDateAndDaysAfterCreation()) { final LocalDate daysAfterCreation = requestDate.plusDays(getNumberOfDaysAfterCreationForDueDate()); if (daysAfterCreation.isAfter(getFixedDueDate())) { return daysAfterCreation; } else { return getFixedDueDate(); } } return requestDate.plusDays(getNumberOfDaysAfterCreationForDueDate()); }
From source file:org.gnucash.android.ui.chart.LineChartActivity.java
License:Apache License
/** * Returns a data object that represents a user data of the specified account types * @param accountTypeList account's types which will be displayed * @return a {@code LineData} instance that represents a user data *//*from w w w . j a v a2 s . c om*/ private LineData getData(List<AccountType> accountTypeList) { calculateEarliestAndLatestTimestamps(accountTypeList); LocalDate startDate = new LocalDate(mEarliestTransactionTimestamp).withDayOfMonth(1); LocalDate endDate = new LocalDate(mLatestTransactionTimestamp).withDayOfMonth(1); List<String> xValues = new ArrayList<>(); while (!startDate.isAfter(endDate)) { xValues.add(startDate.toString(X_AXIS_PATTERN)); Log.d(TAG, "X axis " + startDate.toString("MM yy")); startDate = startDate.plusMonths(1); } List<LineDataSet> dataSets = new ArrayList<>(); for (AccountType accountType : accountTypeList) { LineDataSet set = new LineDataSet(getEntryList(accountType), accountType.toString()); set.setDrawFilled(true); set.setLineWidth(2); set.setColor(COLORS[dataSets.size()]); set.setFillColor(FILL_COLORS[dataSets.size()]); dataSets.add(set); } LineData lineData = new LineData(xValues, dataSets); if (lineData.getYValueSum() == 0) { mChartDataPresent = false; return getEmptyData(); } return lineData; }
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// ww w . j a v a 2 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 getLastAppearance() returns the date the regularity of this * course of appearance ends with.//from w ww . j a va 2 s . c o m * * @return the date of last appearance */ public LocalDate getLastAppearance() { if (super.isEmpty()) { return null; } LocalDate result = super.get(0).getLastAppearance(); for (int index = 1; index < super.size(); index++) { LocalDate lastAppearance = super.get(index).getLastAppearance(); if (lastAppearance.isAfter(result)) { result = lastAppearance; } } return result; }
From source file:org.jenkinsci.plugins.zap.portlet.ZapLoadData.java
License:Open Source License
/** * Get ZAP alert results of all jobs and store into a sorted HashMap by * date./*from w w w . ja va 2 s. c om*/ * * @param jobs * jobs of Dashboard view * @param daysNumber * number of days * @return Map The sorted summaries */ public static Map<LocalDate, ZapAlertResultSummary> loadChartDataWithinRange(List<Job> jobs, int daysNumber) { Map<LocalDate, ZapAlertResultSummary> summaries = new HashMap<LocalDate, ZapAlertResultSummary>(); // Get the last build (last date) of the all jobs LocalDate lastDate = Utils.getLastDate(jobs); // No builds if (lastDate == null) { return null; } // Get the first date from last build date minus number of days LocalDate firstDate = lastDate.minusDays(daysNumber); // For each job, get ZAP alert results according with // date range (last build date minus number of days) for (Job job : jobs) { Run run = job.getLastBuild(); if (null != run) { LocalDate runDate = new LocalDate(run.getTimestamp()); while (runDate.isAfter(firstDate)) { summarize(summaries, run, runDate, job); run = run.getPreviousBuild(); if (null == run) { break; } runDate = new LocalDate(run.getTimestamp()); } } } // Sorting by date, ascending order Map<LocalDate, ZapAlertResultSummary> sortedSummaries = new TreeMap<LocalDate, ZapAlertResultSummary>( summaries); return sortedSummaries; }
From source file:org.killbill.billing.invoice.generator.BillingIntervalDetail.java
License:Apache License
private void calculateEffectiveEndDate() { // We have an endDate and the targetDate is greater or equal to our endDate => return it if (endDate != null && !targetDate.isBefore(endDate)) { effectiveEndDate = endDate;/*w ww.j a va2s.c om*/ return; } if (targetDate.isBefore(firstBillingCycleDate)) { effectiveEndDate = firstBillingCycleDate; return; } final int numberOfMonthsInPeriod = billingPeriod.getNumberOfMonths(); int numberOfPeriods = 0; LocalDate proposedDate = firstBillingCycleDate; while (!proposedDate.isAfter(targetDate)) { proposedDate = firstBillingCycleDate.plusMonths(numberOfPeriods * numberOfMonthsInPeriod); numberOfPeriods += 1; } proposedDate = alignProposedBillCycleDate(proposedDate, billingCycleDay); // The proposedDate is greater to our endDate => return it if (endDate != null && endDate.isBefore(proposedDate)) { effectiveEndDate = endDate; } else { effectiveEndDate = proposedDate; } }