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:com.github.fauu.natrank.service.RankingServiceImpl.java

License:Open Source License

private Ranking createRankingForDate(LocalDate date, Map<Integer, RankingEntry> entryMap) {
    Ranking ranking = new Ranking();
    ranking.setDate(date);//from   w w w. j av  a  2 s  .co m

    DynamicRanking rankingYearBefore = createDynamicForDate(date.minusYears(1));

    Map<Integer, Integer> ranksYearBeforeMap = new HashMap<>();

    for (DynamicRankingEntry entry : rankingYearBefore.getEntries()) {
        ranksYearBeforeMap.put(entry.getTeamInfo().getTeam().getId(), entry.getRank());
    }

    // FIXME: This should take LocalDate instead of String
    List<TeamRating> latestTeamRatingsForTeamByDate = teamRatingRepository
            .findLatestForTeamsByDate(ranking.getDate().toString("yyyy-MM-dd"));
    Map<Integer, TeamRating> latestTeamRatingsMap = new HashMap<>();
    for (TeamRating rating : latestTeamRatingsForTeamByDate) {
        latestTeamRatingsMap.put(rating.getTeam().getId(), rating);
    }

    Map<Integer, RankingEntry> newEntryMap = new HashMap<>();
    for (Map.Entry<Integer, RankingEntry> entry : entryMap.entrySet()) {
        RankingEntry newEntry = new RankingEntry(entry.getValue());

        if (newEntry.getMatchesTotal() >= NUM_TRIAL_MATCHES) {
            newEntry.setRating(latestTeamRatingsMap.get(newEntry.getTeam().getId()).getValue());
        }

        newEntryMap.put(newEntry.getTeam().getId(), newEntry);
    }

    List<RankingEntry> newEntries = new LinkedList<>(newEntryMap.values());

    Collections.sort(newEntries);

    int currentRank = 1;
    for (RankingEntry entry : newEntries) {
        entry.setRanking(ranking);

        if (entry.getRating() != 0) {
            entry.setRank(currentRank);

            if (ranksYearBeforeMap.containsKey(entry.getTeam().getId())) {
                Integer rankYearBefore = ranksYearBeforeMap.get(entry.getTeam().getId());

                if (rankYearBefore != 0) {
                    entry.setRankOneYearChange(rankYearBefore - entry.getRank());
                }
            }

            currentRank++;
        }
    }

    ranking.getEntries().addAll(newEntries);

    return ranking;
}

From source file:com.github.fauu.natrank.service.RankingServiceImpl.java

License:Open Source License

@Override
public DynamicRanking createDynamicForDate(LocalDate date) {
    // FIXME: These should take LocalDate instead of String
    String dateStr = date.toString("yyyy-MM-dd");
    String dateMinusOneYearStr = date.minusYears(1).toString("yyyy-MM-dd");

    List<TeamRating> latestTeamRatingsForTeam = teamRatingRepository.findLatestForTeamsByDate(dateStr);
    List<TeamRank> latestTeamRanksForTeam = teamRankRepository.findLatestForTeamsByDate(dateStr);
    List<TeamRank> teamRanksForTeamOneYearBefore = teamRankRepository
            .findLatestForTeamsByDate(dateMinusOneYearStr);

    DynamicRanking ranking = new DynamicRanking();
    ranking.setFullVariantAvailable(rankingRepository.existsByDate(date));

    Map<Integer, DynamicRankingEntry> rankingEntryMap = new HashMap<>();

    for (TeamRank teamRank : latestTeamRanksForTeam) {
        DynamicRankingEntry rankingEntry = new DynamicRankingEntry();
        rankingEntry.setTeam(teamRank.getTeam());
        rankingEntry.setRanking(ranking);
        rankingEntry.setRank(teamRank.getValue());

        rankingEntryMap.put(teamRank.getTeam().getId(), rankingEntry);
    }/* w w w . java 2 s.  c om*/

    for (TeamRank teamRankOneYearBefore : teamRanksForTeamOneYearBefore) {
        if (rankingEntryMap.containsKey(teamRankOneYearBefore.getTeam().getId())) {
            Integer rankOneYearChange = teamRankOneYearBefore.getValue()
                    - rankingEntryMap.get(teamRankOneYearBefore.getTeam().getId()).getRank();

            rankingEntryMap.get(teamRankOneYearBefore.getTeam().getId())
                    .setRankOneYearChange(rankOneYearChange);
        }
    }

    // Temporary workaround to discard lTRFT duplicates for two matches on the same date
    // (4 April 1909 bug)
    Collections.reverse(latestTeamRatingsForTeam);

    List<Integer> processedTeamIds = new LinkedList<>();
    for (TeamRating teamRating : latestTeamRatingsForTeam) {
        DynamicRankingEntry rankingEntry;

        // Temporary workaround to discard lTRFT duplicates for two matches on the same date
        // (4 April 1909 bug)
        if (!processedTeamIds.contains(teamRating.getTeam().getId())) {
            processedTeamIds.add(teamRating.getTeam().getId());

            if (!rankingEntryMap.containsKey(teamRating.getTeam().getId())) {
                rankingEntry = new DynamicRankingEntry();
                rankingEntry.setTeam(teamRating.getTeam());
                rankingEntry.setRanking(ranking);
                rankingEntry.setRating(0);
                rankingEntry.setRank(0);

                rankingEntryMap.put(teamRating.getTeam().getId(), rankingEntry);
            } else {
                rankingEntry = rankingEntryMap.get(teamRating.getTeam().getId());
                rankingEntry.setRating(teamRating.getValue());
            }
        }
    }

    List<DynamicRankingEntry> rankingEntries = new LinkedList<>(rankingEntryMap.values());

    Collections.sort(rankingEntries);

    ranking.setDate(date);
    ranking.setEntries(rankingEntries);

    return ranking;
}

From source file:com.gst.portfolio.calendar.service.CalendarReadPlatformServiceImpl.java

License:Apache License

private LocalDate getPeriodStartDate(final LocalDate seedDate, final LocalDate recurrenceStartDate,
        final LocalDate fromDate) {
    LocalDate periodStartDate = null;
    if (fromDate != null) {
        periodStartDate = fromDate;//w  ww .  java 2  s  .c om
    } else {
        final LocalDate currentDate = DateUtils.getLocalDateOfTenant();
        if (seedDate.isBefore(currentDate.minusYears(1))) {
            periodStartDate = currentDate.minusYears(1);
        } else {
            periodStartDate = recurrenceStartDate;
        }
    }
    return periodStartDate;
}

From source file:com.gst.portfolio.loanaccount.loanschedule.domain.DefaultScheduledDateGenerator.java

License:Apache License

@Override
public LocalDate idealDisbursementDateBasedOnFirstRepaymentDate(
        final PeriodFrequencyType repaymentPeriodFrequencyType, final int repaidEvery,
        final LocalDate firstRepaymentDate, final Calendar loanCalendar,
        final HolidayDetailDTO holidayDetailDTO, final LoanApplicationTerms loanApplicationTerms) {

    LocalDate idealDisbursementDate = null;

    switch (repaymentPeriodFrequencyType) {
    case DAYS:/*  w  w w.  j  ava  2 s .  com*/
        idealDisbursementDate = firstRepaymentDate.minusDays(repaidEvery);
        break;
    case WEEKS:
        idealDisbursementDate = firstRepaymentDate.minusWeeks(repaidEvery);
        break;
    case MONTHS:
        if (loanCalendar == null) {
            idealDisbursementDate = firstRepaymentDate.minusMonths(repaidEvery);
        } else {
            idealDisbursementDate = CalendarUtils.getNewRepaymentMeetingDate(loanCalendar.getRecurrence(),
                    firstRepaymentDate.minusMonths(repaidEvery), firstRepaymentDate.minusMonths(repaidEvery),
                    repaidEvery,
                    CalendarUtils.getMeetingFrequencyFromPeriodFrequencyType(repaymentPeriodFrequencyType),
                    holidayDetailDTO.getWorkingDays(), loanApplicationTerms.isSkipRepaymentOnFirstDayofMonth(),
                    loanApplicationTerms.getNumberOfdays());
        }
        break;
    case YEARS:
        idealDisbursementDate = firstRepaymentDate.minusYears(repaidEvery);
        break;
    case INVALID:
        break;
    }

    return idealDisbursementDate;
}

From source file:com.squid.kraken.v4.api.core.EngineUtils.java

License:Open Source License

/**
 * Convert the facet value into a date. 
 * If the value start with '=', it is expected to be a Expression, in which case we'll try to resolve it to a Date constant.
 * @param ctx//from w  ww  . ja  va  2s .  c  om
 * @param index
 * @param lower 
 * @param value
 * @param compareFromInterval 
 * @return
 * @throws ParseException
 * @throws ScopeException
 * @throws ComputingException 
 */
public Date convertToDate(Universe universe, DimensionIndex index, Bound bound, String value,
        IntervalleObject compareFromInterval) throws ParseException, ScopeException, ComputingException {
    if (value.equals("")) {
        return null;
    } else if (value.startsWith("__")) {
        //
        // support hard-coded shortcuts
        if (value.toUpperCase().startsWith("__COMPARE_TO_")) {
            // for compareTo
            if (compareFromInterval == null) {
                // invalid compare_to selection...
                return null;
            }
            if (value.equalsIgnoreCase("__COMPARE_TO_PREVIOUS_PERIOD")) {
                LocalDate localLower = new LocalDate(((Date) compareFromInterval.getLowerBound()).getTime());
                if (bound == Bound.UPPER) {
                    LocalDate date = localLower.minusDays(1);
                    return date.toDate();
                } else {
                    LocalDate localUpper = new LocalDate(
                            ((Date) compareFromInterval.getUpperBound()).getTime());
                    Days days = Days.daysBetween(localLower, localUpper);
                    LocalDate date = localLower.minusDays(1 + days.getDays());
                    return date.toDate();
                }
            }
            if (value.equalsIgnoreCase("__COMPARE_TO_PREVIOUS_MONTH")) {
                LocalDate localLower = new LocalDate(((Date) compareFromInterval.getLowerBound()).getTime());
                LocalDate compareLower = localLower.minusMonths(1);
                if (bound == Bound.LOWER) {
                    return compareLower.toDate();
                } else {
                    LocalDate localUpper = new LocalDate(
                            ((Date) compareFromInterval.getUpperBound()).getTime());
                    Days days = Days.daysBetween(localLower, localUpper);
                    LocalDate compareUpper = compareLower.plusDays(days.getDays());
                    return compareUpper.toDate();
                }
            }
            if (value.equalsIgnoreCase("__COMPARE_TO_PREVIOUS_YEAR")) {
                LocalDate localLower = new LocalDate(((Date) compareFromInterval.getLowerBound()).getTime());
                LocalDate compareLower = localLower.minusYears(1);
                if (bound == Bound.LOWER) {
                    return compareLower.toDate();
                } else {
                    LocalDate localUpper = new LocalDate(
                            ((Date) compareFromInterval.getUpperBound()).getTime());
                    Days days = Days.daysBetween(localLower, localUpper);
                    LocalDate compareUpper = compareLower.plusDays(days.getDays());
                    return compareUpper.toDate();
                }
            }
        } else {
            // for regular
            // get MIN, MAX first
            Intervalle range = null;
            if (index.getDimension().getType() == Type.CONTINUOUS) {
                if (index.getStatus() == Status.DONE) {
                    List<DimensionMember> members = index.getMembers();
                    if (!members.isEmpty()) {
                        DimensionMember member = members.get(0);
                        Object object = member.getID();
                        if (object instanceof Intervalle) {
                            range = (Intervalle) object;
                        }
                    }
                } else {
                    try {
                        DomainHierarchy hierarchy = universe
                                .getDomainHierarchy(index.getAxis().getParent().getDomain());
                        hierarchy.isDone(index, null);
                    } catch (ComputingException | InterruptedException | ExecutionException
                            | TimeoutException e) {
                        throw new ComputingException("failed to retrieve period interval");
                    }
                }
            }
            if (range == null) {
                range = IntervalleObject.createInterval(new Date(), new Date());
            }
            if (value.equalsIgnoreCase("__ALL")) {
                if (index.getDimension().getType() != Type.CONTINUOUS) {
                    return null;
                }
                if (bound == Bound.UPPER) {
                    return (Date) range.getUpperBound();
                } else {
                    return (Date) range.getLowerBound();
                }
            }
            if (value.equalsIgnoreCase("__LAST_DAY")) {
                if (bound == Bound.UPPER) {
                    return (Date) range.getUpperBound();
                } else {
                    return (Date) range.getUpperBound();
                }
            }
            if (value.equalsIgnoreCase("__LAST_7_DAYS")) {
                if (bound == Bound.UPPER) {
                    return (Date) range.getUpperBound();
                } else {
                    LocalDate localUpper = new LocalDate(((Date) range.getUpperBound()).getTime());
                    LocalDate date = localUpper.minusDays(6);// 6+1
                    return date.toDate();
                }
            }
            if (value.equalsIgnoreCase("__CURRENT_MONTH")) {
                if (bound == Bound.UPPER) {
                    return (Date) range.getUpperBound();
                } else {
                    LocalDate localUpper = new LocalDate(((Date) range.getUpperBound()).getTime());
                    LocalDate date = localUpper.withDayOfMonth(1);
                    return date.toDate();
                }
            }
            if (value.equalsIgnoreCase("__CURRENT_YEAR")) {
                if (bound == Bound.UPPER) {
                    return (Date) range.getUpperBound();
                } else {
                    LocalDate localUpper = new LocalDate(((Date) range.getUpperBound()).getTime());
                    LocalDate date = localUpper.withMonthOfYear(1).withDayOfMonth(1);
                    return date.toDate();
                }
            }
            if (value.equalsIgnoreCase("__PREVIOUS_MONTH")) {// the previous complete month
                if (bound == Bound.UPPER) {
                    LocalDate localUpper = new LocalDate(((Date) range.getUpperBound()).getTime());
                    LocalDate date = localUpper.withDayOfMonth(1).minusDays(1);
                    return date.toDate();
                } else {
                    LocalDate localUpper = new LocalDate(((Date) range.getUpperBound()).getTime());
                    LocalDate date = localUpper.withDayOfMonth(1).minusMonths(1);
                    return date.toDate();
                }
            }
            if (value.equalsIgnoreCase("__PREVIOUS_YEAR")) {// the previous complete month
                if (bound == Bound.UPPER) {
                    LocalDate localUpper = new LocalDate(((Date) range.getUpperBound()).getTime());
                    LocalDate date = localUpper.withMonthOfYear(1).withDayOfMonth(1).minusDays(1);
                    return date.toDate();
                } else {
                    LocalDate localUpper = new LocalDate(((Date) range.getUpperBound()).getTime());
                    LocalDate date = localUpper.withMonthOfYear(1).withDayOfMonth(1).minusYears(1);
                    return date.toDate();
                }
            }
        }
        throw new ScopeException("undefined facet expression alias: " + value);
    } else if (value.startsWith("=")) {
        // if the value starts by equal token, this is a formula that can be
        // evaluated
        try {
            String expr = value.substring(1);
            // check if the index content is available or wait for it
            DomainHierarchy hierarchy = universe.getDomainHierarchy(index.getAxis().getParent().getDomain(),
                    true);
            hierarchy.isDone(index, null);
            // evaluate the expression
            Object defaultValue = evaluateExpression(universe, index, expr, compareFromInterval);
            // check we can use it
            if (defaultValue == null) {
                //throw new ScopeException("unable to parse the facet expression as a constant: " + expr);
                // T1769: it's ok to return null
                return null;
            }
            if (!(defaultValue instanceof Date)) {
                throw new ScopeException("unable to parse the facet expression as a date: " + expr);
            }
            // ok, it's a date
            return (Date) defaultValue;
        } catch (ComputingException | InterruptedException | ExecutionException | TimeoutException e) {
            throw new ComputingException("failed to retrieve period interval");
        }
    } else {
        Date date = ServiceUtils.getInstance().toDate(value);
        if (bound == Bound.UPPER
                && !index.getAxis().getDefinitionSafe().getImageDomain().isInstanceOf(IDomain.TIME)) {
            // clear the timestamp
            return new LocalDate(date.getTime()).toDate();
        } else {
            return date;
        }
    }
}

From source file:cz.krtinec.birthday.dto.Zodiac.java

License:Open Source License

public static Zodiac toZodiac(LocalDate birthday) {
    for (Zodiac zodiac : values()) {
        LocalDate fromWithYear = zodiac.from.withYear(birthday.getYear());
        LocalDate toWithYear = zodiac.to.withYear(birthday.getYear());

        if (birthday.getMonthOfYear() == 12 && Zodiac.CAPRICORN.equals(zodiac)) {
            toWithYear = toWithYear.plusYears(1);
        } else if (birthday.getMonthOfYear() == 1 && Zodiac.CAPRICORN.equals(zodiac)) {
            fromWithYear = fromWithYear.minusYears(1);
        }// w ww.j  a v  a2s . co  m

        if ((fromWithYear.isBefore(birthday) || fromWithYear.isEqual(birthday))
                && (toWithYear.isAfter(birthday) || toWithYear.isEqual(birthday))) {
            return zodiac;
        }
    }

    throw new IllegalArgumentException("Cannot find zodiac sign for date: " + birthday);
}

From source file:de.appsolve.padelcampus.admin.controller.reports.AdminReportsTimesController.java

@RequestMapping(method = GET)
public ModelAndView getIndex() throws JsonProcessingException {
    LocalDate endDate = new LocalDate();
    LocalDate startDate = endDate.minusYears(1);
    DateRange dateRange = new DateRange();
    dateRange.setStartDate(startDate);//from   w w w.j a v  a 2s. c o  m
    dateRange.setEndDate(endDate);
    return getIndexView(dateRange);
}

From source file:me.vertretungsplan.parser.ParserUtils.java

License:Mozilla Public License

static LocalDate parseDate(String string) {
    if (string == null)
        return null;
    reinitIfNeeded();//from  w w w  .j av a  2  s.co  m

    string = string.replace("Stand:", "").replace("Import:", "").replaceAll(", Woche [A-Z]", "").trim();
    int i = 0;
    for (DateTimeFormatter f : dateFormatters) {
        try {
            LocalDate d = f.parseLocalDate(string);
            if (dateFormats[i].contains("yyyy")) {
                return d;
            } else {
                Duration currentYearDifference = abs(new Duration(DateTime.now(), d.toDateTimeAtCurrentTime()));
                Duration lastYearDifference = abs(
                        new Duration(DateTime.now(), d.minusYears(1).toDateTimeAtCurrentTime()));
                Duration nextYearDifference = abs(
                        new Duration(DateTime.now(), d.plusYears(1).toDateTimeAtCurrentTime()));
                if (lastYearDifference.isShorterThan(currentYearDifference)) {
                    return DateTimeFormat.forPattern(dateFormats[i]).withLocale(Locale.GERMAN)
                            .withDefaultYear(f.getDefaultYear() - 1).parseLocalDate(string);
                } else if (nextYearDifference.isShorterThan(currentYearDifference)) {
                    return DateTimeFormat.forPattern(dateFormats[i]).withLocale(Locale.GERMAN)
                            .withDefaultYear(f.getDefaultYear() + 1).parseLocalDate(string);
                } else {
                    return d;
                }
            }
        } catch (IllegalArgumentException e) {
            // Does not match this format, try the next one
        }
        i++;
    }
    // Does not match any known format :(
    return null;
}

From source file:op.allowance.PnlAllowance.java

License:Open Source License

private CollapsiblePane createCP4(final Resident resident, final int year) {
    LocalDate min = SYSCalendar.bom(minmax.get(resident).getFirst());
    LocalDate max = resident.isActive() ? new LocalDate() : SYSCalendar.eom(minmax.get(resident).getSecond());
    final LocalDate start = new LocalDate(year, 1, 1).isBefore(min.dayOfMonth().withMinimumValue())
            ? min.dayOfMonth().withMinimumValue()
            : new LocalDate(year, 1, 1);
    final LocalDate end = new LocalDate(year, 12, 31).isAfter(max.dayOfMonth().withMaximumValue())
            ? max.dayOfMonth().withMaximumValue()
            : new LocalDate(year, 12, 31);

    final String key = resident.getRID() + "-" + year;
    if (!cpMap.containsKey(key)) {
        cpMap.put(key, new CollapsiblePane());
        try {//from ww w .  j  ava  2 s .com
            cpMap.get(key).setCollapsed(true);
        } catch (PropertyVetoException e) {
            e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
        }

    }

    final CollapsiblePane cpYear = cpMap.get(key);

    if (!carrySums.containsKey(key + "-12")) {
        carrySums.put(key + "-12", AllowanceTools.getSUM(resident, SYSCalendar.eoy(start)));
    }

    String title = "<html><table border=\"0\">" + "<tr>" +

            "<td width=\"520\" align=\"left\"><font size=+1>" + Integer.toString(year) + "</font></td>"
            + "<td width=\"200\" align=\"right\">"
            + (carrySums.get(key + "-12").compareTo(BigDecimal.ZERO) < 0 ? "<font color=\"red\">" : "")
            + cf.format(carrySums.get(key + "-12"))
            + (carrySums.get(key + "-12").compareTo(BigDecimal.ZERO) < 0 ? "</font>" : "") + "</td>" +

            "</tr>" + "</table>" +

            "</font></html>";

    DefaultCPTitle cptitle = new DefaultCPTitle(title, new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            try {
                cpYear.setCollapsed(!cpYear.isCollapsed());
            } catch (PropertyVetoException pve) {
                // BAH!
            }
        }
    });

    GUITools.addExpandCollapseButtons(cpYear, cptitle.getRight());

    /***
     *      ____       _       _ __   __
     *     |  _ \ _ __(_)_ __ | |\ \ / /__  __ _ _ __
     *     | |_) | '__| | '_ \| __\ V / _ \/ _` | '__|
     *     |  __/| |  | | | | | |_ | |  __/ (_| | |
     *     |_|   |_|  |_|_| |_|\__||_|\___|\__,_|_|
     *
     */
    final JButton btnPrintYear = new JButton(SYSConst.icon22print2);
    btnPrintYear.setPressedIcon(SYSConst.icon22print2Pressed);
    btnPrintYear.setAlignmentX(Component.RIGHT_ALIGNMENT);
    btnPrintYear.setContentAreaFilled(false);
    btnPrintYear.setBorder(null);
    btnPrintYear.setToolTipText(SYSTools.xx("misc.tooltips.btnprintyear"));
    btnPrintYear.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent actionEvent) {
            String carry4printKey = resident.getRID() + "-" + (year - 1) + "-12";
            if (!carrySums.containsKey(carry4printKey)) {
                carrySums.put(carry4printKey,
                        AllowanceTools.getSUM(resident, SYSCalendar.eoy(start.minusYears(1))));
            }
            SYSFilesTools.print(AllowanceTools.getAsHTML(AllowanceTools.getYear(resident, start.toDate()),
                    carrySums.get(carry4printKey), resident), true);
        }

    });
    cptitle.getRight().add(btnPrintYear);

    cpYear.setTitleLabelComponent(cptitle.getMain());
    cpYear.setSlidingDirection(SwingConstants.SOUTH);
    cpYear.setBackground(SYSConst.orange1[SYSConst.medium3]);
    cpYear.setOpaque(true);

    /***
     *           _ _      _            _
     *       ___| (_) ___| | _____  __| |   ___  _ __    _   _  ___  __ _ _ __
     *      / __| | |/ __| |/ / _ \/ _` |  / _ \| '_ \  | | | |/ _ \/ _` | '__|
     *     | (__| | | (__|   <  __/ (_| | | (_) | | | | | |_| |  __/ (_| | |
     *      \___|_|_|\___|_|\_\___|\__,_|  \___/|_| |_|  \__, |\___|\__,_|_|
     *                                                   |___/
     */
    cpYear.addCollapsiblePaneListener(new CollapsiblePaneAdapter() {
        @Override
        public void paneExpanded(CollapsiblePaneEvent collapsiblePaneEvent) {
            JPanel pnlContent = new JPanel(new VerticalLayout());

            // somebody clicked on the year
            // monthly informations will be generated. even if there
            // are no allowances for that month
            for (LocalDate month = end; month.compareTo(start) >= 0; month = month.minusMonths(1)) {
                pnlContent.add(createCP4(resident, month));
            }

            cpYear.setContentPane(pnlContent);
            cpYear.setOpaque(false);
        }

    });
    cpYear.setBackground(getBG(resident, 9));

    if (!cpYear.isCollapsed()) {
        JPanel pnlContent = new JPanel(new VerticalLayout());
        for (LocalDate month = end; month.compareTo(start) > 0; month = month.minusMonths(1)) {
            pnlContent.add(createCP4(resident, month));
        }
        cpYear.setContentPane(pnlContent);
    }

    cpYear.setHorizontalAlignment(SwingConstants.LEADING);
    cpYear.setOpaque(false);

    return cpYear;
}

From source file:org.activiti.dmn.engine.impl.mvel.extension.DateUtil.java

License:Apache License

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

    LocalDate currentDate = new LocalDate(startDate);

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

    return currentDate.toDate();
}