Example usage for org.joda.time LocalDate minusYears

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

Introduction

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

Prototype

public LocalDate minusYears(int years) 

Source Link

Document

Returns a copy of this date minus the specified number of years.

Usage

From source file:org.apache.fineract.portfolio.loanaccount.loanschedule.domain.DefaultScheduledDateGenerator.java

License:Apache License

@Override
public LocalDate idealDisbursementDateBasedOnFirstRepaymentDate(
        final PeriodFrequencyType repaymentPeriodFrequencyType, final int repaidEvery,
        final LocalDate firstRepaymentDate) {

    LocalDate idealDisbursementDate = null;

    switch (repaymentPeriodFrequencyType) {
    case DAYS://from w  w w.  ja  v a2 s.  c om
        idealDisbursementDate = firstRepaymentDate.minusDays(repaidEvery);
        break;
    case WEEKS:
        idealDisbursementDate = firstRepaymentDate.minusWeeks(repaidEvery);
        break;
    case MONTHS:
        idealDisbursementDate = firstRepaymentDate.minusMonths(repaidEvery);
        break;
    case YEARS:
        idealDisbursementDate = firstRepaymentDate.minusYears(repaidEvery);
        break;
    case INVALID:
        break;
    }

    return idealDisbursementDate;
}

From source file:org.flowable.dmn.engine.impl.el.util.DateUtil.java

License:Apache License

public static Date subtractDate(Object startDate, Object years, Object months, Object days) {

    LocalDate currentDate = new LocalDate(startDate);

    currentDate = currentDate.minusYears(intValue(years));
    currentDate = currentDate.minusMonths(intValue(months));
    currentDate = currentDate.minusDays(intValue(days));

    return currentDate.toDate();
}

From source file:org.kuali.kpme.core.leaveplan.service.LeavePlanServiceImpl.java

License:Educational Community License

@Override
public DateTime getFirstDayOfLeavePlan(String leavePlan, LocalDate asOfDate) {
    //The only thing this method does is tack on the year of the supplied asOfDate to the calendar year start date.
    LeavePlan lp = getLeavePlan(leavePlan, asOfDate);

    int priorYearCutOffMonth = Integer.parseInt(lp.getCalendarYearStartMonth());
    int priorYearCutOffDay = Integer.parseInt(lp.getCalendarYearStartDayOfMonth());

    LocalDate cutOffDate = asOfDate.withMonthOfYear(priorYearCutOffMonth).withDayOfMonth(priorYearCutOffDay);
    if (asOfDate.isBefore(cutOffDate)) {
        cutOffDate = cutOffDate.minusYears(1);
    }/* w  w w  .ja  va  2s.  com*/
    return cutOffDate.toDateTimeAtStartOfDay();
}

From source file:org.kuali.kpme.tklm.leave.accrual.service.AccrualCategoryMaxCarryOverServiceImpl.java

License:Educational Community License

private BigDecimal getAccrualCategoryBalance(String principalId, AccrualCategory accrualCategory,
        LocalDate endDate) {
    BigDecimal accrualCategoryBalance = BigDecimal.ZERO;

    LocalDate beginDate = endDate.minusYears(1);
    List<LeaveBlock> leaveBlocks = getLeaveBlockService().getLeaveBlocks(principalId, beginDate, endDate);

    for (LeaveBlock leaveBlock : leaveBlocks) {
        if (StringUtils.equals(leaveBlock.getAccrualCategory(), accrualCategory.getAccrualCategory())) {
            if (StringUtils.equals(leaveBlock.getRequestStatus(), HrConstants.REQUEST_STATUS.APPROVED)) {
                accrualCategoryBalance = accrualCategoryBalance.add(leaveBlock.getLeaveAmount());
            }/*from   www  . j  av  a  2  s.  c o m*/
        }
    }

    return accrualCategoryBalance;
}

From source file:org.kuali.kpme.tklm.leave.accrual.service.AccrualServiceImpl.java

License:Educational Community License

@Override
public void calculateFutureAccrualUsingPlanningMonth(String principalId, LocalDate asOfDate,
        String runAsPrincipalId) {
    PrincipalHRAttributes phra = HrServiceLocator.getPrincipalHRAttributeService()
            .getPrincipalCalendar(principalId, asOfDate);
    if (phra != null) {
        // use the date from pay period to get the leave plan
        LeavePlan lp = HrServiceLocator.getLeavePlanService().getLeavePlan(phra.getLeavePlan(), asOfDate);
        if (lp != null && StringUtils.isNotEmpty(lp.getPlanningMonths())) {
            // go back a year 
            LocalDate startDate = asOfDate.minusYears(1);
            if (startDate.getDayOfMonth() > startDate.dayOfMonth().getMaximumValue()) {
                startDate = startDate.withDayOfMonth(startDate.dayOfMonth().getMaximumValue());
            }/*from  w ww.  java 2  s  .com*/
            // go forward using planning months
            LocalDate endDate = asOfDate.plusMonths(Integer.parseInt(lp.getPlanningMonths()));
            // max days in months differ, if the date is bigger than the max day, set it to the max day of the month
            if (endDate.getDayOfMonth() > endDate.dayOfMonth().getMaximumValue()) {
                endDate = endDate.withDayOfMonth(endDate.dayOfMonth().getMaximumValue());
            }
            runAccrual(principalId, startDate.toDateTimeAtStartOfDay(), endDate.toDateTimeAtStartOfDay(), true,
                    runAsPrincipalId);

        }
    }
}

From source file:org.ojbc.web.portal.controllers.dto.PersonFilterCommand.java

License:RPL License

private void computeDOBRangeFromAgeRange() {

    if (filterAgeRangeStart == null) {
        filterDOBStart = "";
        filterDOBEnd = "";
    } else {//from w  ww .  j  a  va  2s  .  com
        LocalDate today = new LocalDate();

        LocalDate computedStartDOB = today.minusYears(filterAgeRangeEnd).minusYears(1).plusDays(1);
        filterDOBStart = computedStartDOB.toString("yyyy-MM-dd");

        LocalDate computedEndDOB = today.minusYears(filterAgeRangeStart);
        filterDOBEnd = computedEndDOB.toString("yyyy-MM-dd");
    }
}

From source file:org.zkoss.ganttz.FunctionalityExposedForExtensions.java

License:Open Source License

public FunctionalityExposedForExtensions(Planner planner, PlannerConfiguration<T> configuration,
        GanttZKDiagramGraph diagramGraph) {

    this.planner = planner;
    this.configuration = configuration;
    this.adapter = configuration.getAdapter();
    this.navigator = configuration.getNavigator();
    this.diagramGraph = diagramGraph;

    final IDetailItemModifier firstLevelModifiers = configuration.getFirstLevelModifiers();
    final IDetailItemModifier secondLevelModifiers = configuration.getSecondLevelModifiers();

    Calendar calendarRightNow = Calendar.getInstance();
    LocalDate localDateRightNow = LocalDate.fromCalendarFields(calendarRightNow);
    LocalDate initDate = localDateRightNow.minusYears(1);
    LocalDate endDate = localDateRightNow.plusYears(5);

    this.timeTracker = new TimeTracker(
            new Interval(TimeTrackerState.year(initDate.getYear()), TimeTrackerState.year(endDate.getYear())),
            planner.getZoomLevel(), firstLevelModifiers, secondLevelModifiers, planner);
}