Example usage for org.joda.time LocalDate getYear

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

Introduction

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

Prototype

public int getYear() 

Source Link

Document

Get the year field value.

Usage

From source file:org.libreplan.web.costcategories.ResourcesCostCategoryAssignmentController.java

License:Open Source License

/**
 * Append a Datebox "end date" to row.//from w  w w .  ja  va2 s  .c  om
 *
 * @param row
 */
private void appendDateboxEndDate(Row row) {
    Datebox endDateBox = new Datebox();
    bindDateboxEndDate(endDateBox, row.getValue());
    LocalDate initDate = ((ResourcesCostCategoryAssignment) row.getValue()).getInitDate();

    if (initDate != null) {
        endDateBox.setConstraint("after " + String.format("%04d", initDate.getYear())
                + String.format("%02d", initDate.getMonthOfYear())
                + String.format("%02d", initDate.getDayOfMonth()));
    }
    row.appendChild(endDateBox);
}

From source file:org.libreplan.web.costcategories.ResourcesCostCategoryAssignmentController.java

License:Open Source License

/**
 * Binds Datebox "init date" to the corresponding attribute of a {@link ResourcesCostCategoryAssignment}.
 *
 * @param dateBoxEndDate//from w w  w  .j  av  a  2  s .  com
 * @param assignment
 */
private void bindDateboxEndDate(final Datebox dateBoxEndDate,
        final ResourcesCostCategoryAssignment assignment) {
    Util.bind(dateBoxEndDate, new Util.Getter<Date>() {
        @Override
        public Date get() {
            LocalDate dateTime = assignment.getEndDate();
            /* TODO resolve deprecated */
            return dateTime != null
                    ? new Date(dateTime.getYear() - 1900, dateTime.getMonthOfYear() - 1,
                            dateTime.getDayOfMonth())
                    : null;
        }
    }, new Util.Setter<Date>() {
        @Override
        public void set(Date value) {
            if (value != null) {
                /* TODO resolve deprecated */
                assignment.setEndDate(
                        new LocalDate(value.getYear() + 1900, value.getMonth() + 1, value.getDate()));
            } else {
                assignment.setEndDate(null);
            }
        }
    });
}

From source file:org.libreplan.web.montecarlo.MonteCarloGraphController.java

License:Open Source License

private String weekAndYearLabelFor(LocalDate date) {
    return "W" + date.getWeekOfWeekyear() + "-" + date.getYear();
}

From source file:org.libreplan.web.planner.allocation.AdvancedAllocationController.java

License:Open Source License

private boolean isBeforeLatestConsolidation(DetailItem item) {
    if (!(task).hasConsolidations())
        return false;

    LocalDate d = ((Task) task).getFirstDayNotConsolidated().getDate();

    DateTime firstDayNotConsolidated = new DateTime(d.getYear(), d.getMonthOfYear(), d.getDayOfMonth(), 0, 0, 0,
            0);/*ww w  .j  a va2 s  .c  om*/

    return item.getStartDate().compareTo(firstDayNotConsolidated) < 0;
}

From source file:org.libreplan.web.users.dashboard.PersonalTimesheetDTO.java

License:Open Source License

/**
 * Returns a string representing the personal timehseet in a given
 * <code>date</code> depending on the <code>periodicity</code>.
 *///from w ww .ja  va2s  . co  m
public static String toString(PersonalTimesheetsPeriodicityEnum periodicity, LocalDate date) {
    switch (periodicity) {

    case WEEKLY:
        LocalDate start = periodicity.getStart(date);
        LocalDate end = periodicity.getEnd(date);

        String string = date.toString("w");
        if (start.getMonthOfYear() == end.getMonthOfYear()) {
            string += " (" + date.toString(MMMM_Y_PATTERN) + ")";
        } else {
            if (start.getYear() == end.getYear()) {
                string += " (" + start.toString("MMMM") + " - " + end.toString(MMMM_Y_PATTERN) + ")";
            } else {
                string += " (" + start.toString(MMMM_Y_PATTERN) + " - " + end.toString(MMMM_Y_PATTERN) + ")";
            }
        }
        return _("Week {0}", string);

    case TWICE_MONTHLY:
        return (date.getDayOfMonth() <= 15) ? _("{0} 1st fortnight", date.toString(MMMM_Y_PATTERN))
                : _("{0} 2nd fortnight", date.toString(MMMM_Y_PATTERN));

    case MONTHLY:
    default:
        return date.toString(MMMM_Y_PATTERN);
    }
}

From source file:org.libreplan.ws.common.impl.DateConverter.java

License:Open Source License

/**
 * It converts a <code>Date</code> to a <code>XMLGregorianCalendar</code>
 * representing a <code>xsd:date</code> XML type.<br/>
 * <br/>/*from  ww  w  . ja v a2 s  .com*/
 *
 * If the date passed as a parameter is <code>null</code>, it also returns
 * <code>null</code>.
 *
 * @throws DatatypeConfigurationException
 */
public final static XMLGregorianCalendar toXMLGregorianCalendar(LocalDate localDate) {
    if (localDate == null) {
        return null;
    } else {
        DatatypeFactory factory;
        try {
            factory = DatatypeFactory.newInstance();
        } catch (DatatypeConfigurationException e) {
            throw new RuntimeException(e);
        }
        return factory.newXMLGregorianCalendarDate(localDate.getYear(), localDate.getMonthOfYear(),
                localDate.getDayOfMonth(), DatatypeConstants.FIELD_UNDEFINED);
    }
}

From source file:org.mifos.accounts.savings.interest.CalendarPeriodHelper.java

License:Open Source License

/**
 * determines all possible periods from the start of the fiscal year of the accounts first activity date.
 *///from   w ww  .j a va  2 s . c o m
public List<CalendarPeriod> determineAllPossiblePeriods(LocalDate firstActivityDate,
        InterestScheduledEvent interestCalculationEvent, LocalDate endDateOfLastPeriod) {

    List<CalendarPeriod> validIntervals = new ArrayList<CalendarPeriod>();

    // fiscal start of year is jan-01 so begin at jan-01 of first deposit.
    LocalDate startOfFiscalYearOfFirstDeposit = new LocalDate(
            new DateTime().withYearOfEra(firstActivityDate.getYear()).withMonthOfYear(1).withDayOfMonth(1));

    List<LocalDate> allMatchingDates = interestCalculationEvent
            .findAllMatchingDatesFromBaseDateUpToAndIncludingNearestMatchingEndDate(
                    startOfFiscalYearOfFirstDeposit, endDateOfLastPeriod);
    for (LocalDate matchingDate : allMatchingDates) {
        LocalDate firstDayofInterval = interestCalculationEvent
                .findFirstDateOfPeriodForMatchingDate(matchingDate);

        CalendarPeriod interval = new CalendarPeriod(firstDayofInterval, matchingDate);
        if (interval.contains(firstActivityDate)) {
            if (matchingDate.isAfter(endDateOfLastPeriod)) {
                interval = new CalendarPeriod(firstActivityDate, endDateOfLastPeriod);
            } else {
                interval = new CalendarPeriod(firstActivityDate, matchingDate);
            }
            validIntervals.add(interval);
        } else if (matchingDate.isAfter(firstActivityDate) && matchingDate.isBefore(endDateOfLastPeriod)
                || matchingDate.isEqual(endDateOfLastPeriod)) {
            validIntervals.add(interval);
        } else if (matchingDate.isAfter(endDateOfLastPeriod)
                && (firstDayofInterval.isBefore(endDateOfLastPeriod)
                        || firstDayofInterval.isEqual(endDateOfLastPeriod))) {
            interval = new CalendarPeriod(firstDayofInterval, endDateOfLastPeriod);
            validIntervals.add(interval);
        }
    }

    return validIntervals;
}

From source file:org.mifos.accounts.savings.struts.actionforms.SavingsApplyAdjustmentActionForm.java

License:Open Source License

public void setTrxnDate(LocalDate trxnDate) {
    if (trxnDate == null) {
        trxnDateDD = null;/*from  w  ww. ja va  2 s. co m*/
        trxnDateMM = null;
        trxnDateYY = null;
    } else {
        trxnDateDD = String.valueOf(trxnDate.getDayOfMonth());
        trxnDateMM = String.valueOf(trxnDate.getMonthOfYear());
        trxnDateYY = String.valueOf(trxnDate.getYear());
    }
}

From source file:org.mifos.platform.cashflow.ui.controller.CashFlowController.java

License:Open Source License

private boolean isSameMonthYear(LocalDate date, LocalDate comparedWith) {
    return date.getYear() == comparedWith.getYear() && (date.getMonthOfYear() == comparedWith.getMonthOfYear());
}

From source file:org.mifos.test.acceptance.framework.loan.AccountChangeStatusPage.java

License:Open Source License

private void populateFields(EditAccountStatusParameters editAccountStatusParameters) {
    selenium.check("name=newStatusId value=" + editAccountStatusParameters.getAccountStatus().getId());
    selenium.fireEvent("name=newStatusId value=" + editAccountStatusParameters.getAccountStatus().getId(),
            "click");

    if (editAccountStatusParameters.getTrxnDate() != null) {
        LocalDate trxnDate = editAccountStatusParameters.getTrxnDate();
        selenium.type("transactionDateDD", String.valueOf(trxnDate.getDayOfMonth()));
        selenium.fireEvent("transactionDateDD", "blur");
        selenium.type("transactionDateMM", String.valueOf(trxnDate.getMonthOfYear()));
        selenium.fireEvent("transactionDateMM", "blur");
        selenium.type("transactionDateYY", String.valueOf(trxnDate.getYear()));
        selenium.fireEvent("transactionDateYY", "blur");
    }//from   w  w w  .java 2  s  .  co m
    selenium.type("change_status.input.note", editAccountStatusParameters.getNote());
}