Java Code Examples for org.joda.time.LocalDate#plusYears()

The following examples show how to use org.joda.time.LocalDate#plusYears() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PaperclipsForInvoiceForLeaseRepository.java    From estatio with Apache License 2.0 7 votes vote down vote up
/**
 * It's necessary to use the low-level API because the candidate class ({@link PaperclipForInvoice}) and the
 * result class ({@link InvoiceForLease}) are different.
 */
@Programmatic
public List<InvoiceForLease> findInvoicesByYearWithSupportingDocuments(final int year) {

    final PersistenceManager jdoPersistenceManager = isisJdoSupport.getJdoPersistenceManager();
    final Query query = jdoPersistenceManager.newNamedQuery(
            PaperclipForInvoice.class,
            "findInvoicesByInvoiceDateBetweenWithSupportingDocuments");
    query.setResultClass(InvoiceForLease.class);

    try {
        final LocalDate invoiceDateFrom = new LocalDate(year,1,1);
        final LocalDate invoiceDateTo = invoiceDateFrom.plusYears(1);

        final List results = (List) query.executeWithMap(ImmutableMap.of(
                "invoiceDateFrom", invoiceDateFrom,
                "invoiceDateTo", invoiceDateTo
        ));
        return Lists.newArrayList(results);
    } finally {
        query.closeAll();
    }
}
 
Example 2
Source File: YearIterator.java    From dhis2-android-datacapture with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
protected ArrayList<DateHolder> generatePeriod() {
    ArrayList<DateHolder> dates = new ArrayList<DateHolder>();
    int counter = 0;
    checkDate = new LocalDate(cPeriod);

    while ((openFuturePeriods > 0 || currentDate.isAfter(checkDate.plusYears(1))) && counter < 10) {
        String date = checkDate.year().getAsString();

        if (checkDate.isBefore(maxDate) && isInInputPeriods(date)) {
            DateHolder dateHolder = new DateHolder(date, checkDate.toString(), date);
            dates.add(dateHolder);
        }
        checkDate = checkDate.plusYears(1);
        counter++;
    }

    Collections.reverse(dates);
    return dates;
}
 
Example 3
Source File: TestDateUtils.java    From joda-time-android with Apache License 2.0 6 votes vote down vote up
@Test
public void testGetRelativeTimeSpanStringWithPreposition() {
    Context ctx = InstrumentationRegistry.getInstrumentation().getContext();

    LocalDate today = LocalDate.now();
    LocalDate tomorrow = today.plusDays(1);
    LocalDate nextYear = today.plusYears(1);

    assertEquals("12:35", DateUtils.getRelativeTimeSpanString(ctx, today, false));
    assertEquals("at 12:35", DateUtils.getRelativeTimeSpanString(ctx, today, true));
    assertEquals("Oct 23, 1995", DateUtils.getRelativeTimeSpanString(ctx, tomorrow, false));
    assertEquals("on Oct 23, 1995", DateUtils.getRelativeTimeSpanString(ctx, tomorrow, true));
    assertEquals("10/22/1996", DateUtils.getRelativeTimeSpanString(ctx, nextYear, false));
    assertEquals("on 10/22/1996", DateUtils.getRelativeTimeSpanString(ctx, nextYear, true));

    DateTime todayDt = DateTime.now();
    DateTime tomorrowDt = todayDt.plusDays(1);
    DateTime nextYearDt = todayDt.plusYears(1);

    assertEquals("12:35", DateUtils.getRelativeTimeSpanString(ctx, todayDt, false));
    assertEquals("at 12:35", DateUtils.getRelativeTimeSpanString(ctx, todayDt, true));
    assertEquals("Oct 23, 1995", DateUtils.getRelativeTimeSpanString(ctx, tomorrowDt, false));
    assertEquals("on Oct 23, 1995", DateUtils.getRelativeTimeSpanString(ctx, tomorrowDt, true));
    assertEquals("10/22/1996", DateUtils.getRelativeTimeSpanString(ctx, nextYearDt, false));
    assertEquals("on 10/22/1996", DateUtils.getRelativeTimeSpanString(ctx, nextYearDt, true));
}
 
Example 4
Source File: LeaseTermForTurnoverRentInvoicedByManagerImport.java    From estatio with Apache License 2.0 6 votes vote down vote up
@Programmatic
@Override
public List<Object> importData(final Object previousRow) {
    LeaseItem item = importItem();
    LeaseTermForTurnoverRent term = (LeaseTermForTurnoverRent) item.findTerm(termStartDate);
    if (term==null) {
        if (!item.getTerms().isEmpty()){
            LocalDate nextStartDate = item.getTerms().last().getStartDate().plusYears(1);
            while (nextStartDate.isBefore(termStartDate)){
                LeaseTermForTurnoverRent emptyTerm = (LeaseTermForTurnoverRent) item.newTerm(nextStartDate, null);
                emptyTerm.setManualTurnoverRent(BigDecimal.ZERO);
                emptyTerm.setStatus(LeaseTermStatus.APPROVED);
                nextStartDate = nextStartDate.plusYears(1);
                transactionService3.nextTransaction(); // needed because of DN behaviour...
            }
        }
        term = (LeaseTermForTurnoverRent) item.newTerm(termStartDate, null);
    }
    // always overwrite manual turnover rent and status
    term.setManualTurnoverRent(rentNetAmount);
    term.setStatus(LeaseTermStatus.APPROVED);
    return Lists.newArrayList(term);
}
 
Example 5
Source File: YearIterator.java    From dhis2-android-datacapture with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public YearIterator(int openFP, String[] dataInputPeriods) {
    super(dataInputPeriods);
    openFuturePeriods = openFP;
    cPeriod = new LocalDate(currentDate.getYear(), JAN, 1);
    checkDate = new LocalDate(cPeriod);
    maxDate = new LocalDate(currentDate.getYear(), JAN, 1);
    for (int i = 0; i < openFuturePeriods; i++) {
        maxDate = maxDate.plusYears(1);
    }
}
 
Example 6
Source File: DateUtil.java    From activiti6-boot2 with Apache License 2.0 3 votes vote down vote up
public static Date addDate(Date startDate, Integer years, Integer months, Integer days) {

        LocalDate currentDate = new LocalDate(startDate);

        currentDate = currentDate.plusYears(years);
        currentDate = currentDate.plusMonths(months);
        currentDate = currentDate.plusDays(days);

        return currentDate.toDate();
    }
 
Example 7
Source File: DateUtil.java    From flowable-engine with Apache License 2.0 3 votes vote down vote up
public static Date addDate(Object startDate, Object years, Object months, Object days) {

        LocalDate currentDate = new LocalDate(startDate);
        
        currentDate = currentDate.plusYears(intValue(years));
        currentDate = currentDate.plusMonths(intValue(months));
        currentDate = currentDate.plusDays(intValue(days));

        return currentDate.toDate();
    }