Example usage for org.joda.time LocalDate plusYears

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

Introduction

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

Prototype

public LocalDate plusYears(int years) 

Source Link

Document

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

Usage

From source file:org.kuali.kpme.core.calendar.entry.dao.CalendarEntryDaoOjbImpl.java

License:Educational Community License

public List<CalendarEntry> getAllCalendarEntriesForCalendarIdAndYear(String hrCalendarId, String year) {
    Criteria crit = new Criteria();
    List<CalendarEntry> ceList = new ArrayList<CalendarEntry>();
    crit.addEqualTo("hrCalendarId", hrCalendarId);
    DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyy");
    LocalDate currentYear = formatter.parseLocalDate(year);
    LocalDate nextYear = currentYear.plusYears(1);
    crit.addGreaterOrEqualThan("beginPeriodDateTime", currentYear.toDate());
    crit.addLessThan("beginPeriodDateTime", nextYear.toDate());

    QueryByCriteria query = new QueryByCriteria(CalendarEntry.class, crit);
    Collection c = this.getPersistenceBrokerTemplate().getCollectionByQuery(query);
    if (c != null) {
        ceList.addAll(c);//from  w  w w. j  av  a  2 s . c o  m
    }
    return ceList;
}

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

License:Educational Community License

@Override
public DateTime getRolloverDayOfLeavePlan(String leavePlan, LocalDate asOfDate) {
    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.isAfter(cutOffDate) || asOfDate.equals(cutOffDate)) {
        cutOffDate = cutOffDate.plusYears(1);
    }//from   www  .  j  a  v  a  2s . com
    return cutOffDate.toDateTimeAtStartOfDay();
}

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

License:Educational Community License

public List<AccrualCategoryRule> getAccrualCategoryRulesForDate(List<AccrualCategoryRule> acrList,
        String accrualCategoryId, LocalDate currentDate, LocalDate serviceDate) {
    List<AccrualCategoryRule> aList = new ArrayList<AccrualCategoryRule>();
    if (CollectionUtils.isNotEmpty(acrList)) {
        for (AccrualCategoryRule acr : acrList) {
            if (acr.getLmAccrualCategoryId().equals(accrualCategoryId)) {
                String uot = acr.getServiceUnitOfTime();
                int startTime = acr.getStart().intValue();
                int endTime = acr.getEnd().intValue();

                LocalDate startDate = serviceDate;
                LocalDate endDate = serviceDate;
                if (uot.equals("M")) { // monthly
                    startDate = startDate.plusMonths(startTime);
                    endDate = endDate.plusMonths(endTime).minusDays(1);
                } else if (uot.endsWith("Y")) { // yearly
                    startDate = startDate.plusYears(startTime);
                    endDate = endDate.plusYears(endTime).minusDays(1);
                }/*from   w  ww  .j  a  v  a2  s . c om*/

                // max days in months differ, if the date is bigger than the max day, set it to the max day of the month
                if (startDate.getDayOfMonth() > startDate.dayOfMonth().getMaximumValue()) {
                    startDate = startDate.withDayOfMonth(startDate.dayOfMonth().getMaximumValue());
                }
                if (endDate.getDayOfMonth() > endDate.dayOfMonth().getMaximumValue()) {
                    endDate = endDate.withDayOfMonth(endDate.dayOfMonth().getMaximumValue());
                }

                if (currentDate.compareTo(startDate) >= 0 && currentDate.compareTo(endDate) <= 0) {
                    aList.add(acr);
                }
            }
        }
    }
    return aList;
}

From source file:org.kuali.kpme.tklm.time.workflow.dao.TimesheetDocumentHeaderDaoOjbImpl.java

License:Educational Community License

public List<TimesheetDocumentHeader> getDocumentHeadersForYear(String principalId, String year) {
    Criteria crit = new Criteria();
    List<TimesheetDocumentHeader> lstDocumentHeaders = new ArrayList<TimesheetDocumentHeader>();

    crit.addEqualTo("principalId", principalId);
    DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyy");
    LocalDate currentYear = formatter.parseLocalDate(year);
    LocalDate nextYear = currentYear.plusYears(1);
    crit.addGreaterOrEqualThan("beginDate", currentYear.toDate());
    crit.addLessThan("beginDate", nextYear.toDate());

    QueryByCriteria query = new QueryByCriteria(TimesheetDocumentHeader.class, crit);
    Collection c = this.getPersistenceBrokerTemplate().getCollectionByQuery(query);
    if (c != null) {
        lstDocumentHeaders.addAll(c);//from  w  w w  .  j a va 2 s.  co  m
    }

    return lstDocumentHeaders;
}

From source file:org.zkoss.ganttz.data.resourceload.LoadTimeLine.java

License:Open Source License

public static Interval getIntervalFrom(List<LoadTimeLine> timeLines) {
    GanttDate start = null;//from w w  w .ja  v a  2s  .  co  m
    GanttDate end = null;

    for (LoadTimeLine loadTimeLine : timeLines) {
        if (!loadTimeLine.isEmpty()) {
            Validate.notNull(loadTimeLine.getStart());
            start = min(start, loadTimeLine.getStart());
            Validate.notNull(loadTimeLine.getEnd());
            end = max(end, loadTimeLine.getEnd());
        }
    }

    if (timeLines.isEmpty() || start == null || end == null) {
        LocalDate localDateNow = new LocalDate();

        return new Interval(localDateNow, localDateNow.plusYears(5));
    }

    return new Interval(start.toLocalDate(), end.asExclusiveEnd());
}

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);
}

From source file:org.zkoss.ganttz.timetracker.zoom.DetailThreeTimeTrackerState.java

License:Open Source License

@Override
protected LocalDate round(LocalDate date, boolean down) {
    if ((date.getMonthOfYear() == 1 || date.getMonthOfYear() == 7) && date.getDayOfMonth() == 1) {
        return date;
    }/*ww w  . ja v  a 2 s .  c  o m*/

    date = date.withDayOfMonth(1);

    if (date.getMonthOfYear() < 7) {
        return down ? date.withMonthOfYear(1) : date.withMonthOfYear(7);
    } else {
        return down ? date.withMonthOfYear(7) : date.plusYears(1).withMonthOfYear(1);
    }
}