Example usage for org.joda.time LocalDate plusMonths

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

Introduction

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

Prototype

public LocalDate plusMonths(int months) 

Source Link

Document

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

Usage

From source file:com.ning.billing.invoice.tests.inAdvance.GenericProRationTestBase.java

License:Apache License

@Test(groups = "fast")
public void testSinglePlan_OnePeriodLessADayAfterStart() throws InvalidDateSequenceException {
    final LocalDate startDate = invoiceUtil.buildDate(2011, 2, 15);
    final LocalDate targetDate = startDate.plusMonths(getBillingPeriod().getNumberOfMonths()).plusDays(-1);

    testCalculateNumberOfBillingCycles(startDate, targetDate, 15, ONE);
}

From source file:com.ning.billing.invoice.tests.inAdvance.GenericProRationTestBase.java

License:Apache License

@Test(groups = "fast")
public void testSinglePlan_ExactlyOnePeriodAfterStart() throws InvalidDateSequenceException {
    final LocalDate startDate = invoiceUtil.buildDate(2011, 2, 15);
    final LocalDate targetDate = startDate.plusMonths(getBillingPeriod().getNumberOfMonths());

    testCalculateNumberOfBillingCycles(startDate, targetDate, 15, TWO);
}

From source file:com.ning.billing.invoice.tests.inAdvance.GenericProRationTestBase.java

License:Apache License

@Test(groups = "fast")
public void testSinglePlan_SlightlyMoreThanOnePeriodAfterStart() throws InvalidDateSequenceException {
    final LocalDate startDate = invoiceUtil.buildDate(2011, 2, 15);
    final LocalDate targetDate = startDate.plusMonths(getBillingPeriod().getNumberOfMonths()).plusDays(1);

    testCalculateNumberOfBillingCycles(startDate, targetDate, 15, TWO);
}

From source file:com.ning.billing.invoice.tests.inAdvance.GenericProRationTestBase.java

License:Apache License

@Test(groups = "fast")
public void testSinglePlan_CrossingYearBoundary() throws InvalidDateSequenceException {
    final LocalDate startDate = invoiceUtil.buildDate(2011, 12, 15);
    final LocalDate oneCycleLater = startDate.plusMonths(getBillingPeriod().getNumberOfMonths());

    // test just before the billing cycle day
    testCalculateNumberOfBillingCycles(startDate, oneCycleLater.plusDays(-1), 15, ONE);

    // test on the billing cycle day
    testCalculateNumberOfBillingCycles(startDate, oneCycleLater, 15, TWO);

    // test just after the billing cycle day
    testCalculateNumberOfBillingCycles(startDate, oneCycleLater.plusDays(1), 15, TWO);
}

From source file:com.ning.billing.invoice.tests.inAdvance.GenericProRationTestBase.java

License:Apache License

@Test(groups = "fast")
public void testSinglePlan_StartingMidFebruary() throws InvalidDateSequenceException {
    final LocalDate startDate = invoiceUtil.buildDate(2011, 2, 15);
    final LocalDate targetDate = startDate.plusMonths(getBillingPeriod().getNumberOfMonths());

    testCalculateNumberOfBillingCycles(startDate, targetDate, 15, TWO);
}

From source file:com.ning.billing.invoice.tests.inAdvance.GenericProRationTestBase.java

License:Apache License

@Test(groups = "fast")
public void testSinglePlan_StartingMidFebruaryOfLeapYear() throws InvalidDateSequenceException {
    final LocalDate startDate = invoiceUtil.buildDate(2012, 2, 15);
    final LocalDate targetDate = startDate.plusMonths(getBillingPeriod().getNumberOfMonths());

    testCalculateNumberOfBillingCycles(startDate, targetDate, 15, TWO);
}

From source file:com.ning.billing.invoice.tests.inAdvance.GenericProRationTestBase.java

License:Apache License

@Test(groups = "fast")
public void testSinglePlan_MovingForwardThroughTime() throws InvalidDateSequenceException {
    final LocalDate startDate = invoiceUtil.buildDate(2011, 1, 31);
    BigDecimal expectedValue = ONE;

    for (int i = 1; i <= 12; i++) {
        final LocalDate oneCycleLater = startDate.plusMonths(i * getBillingPeriod().getNumberOfMonths());
        // test just before the billing cycle day
        testCalculateNumberOfBillingCycles(startDate, oneCycleLater.plusDays(-1), 31, expectedValue);

        expectedValue = expectedValue.add(ONE);

        // test on the billing cycle day
        testCalculateNumberOfBillingCycles(startDate, oneCycleLater, 31, expectedValue);

        // test just after the billing cycle day
        testCalculateNumberOfBillingCycles(startDate, oneCycleLater.plusDays(1), 31, expectedValue);
    }//from  w ww. j ava 2  s  . c  o  m
}

From source file:com.stagecents.pay.domain.PayCycle.java

License:Open Source License

public LocalDate getCycleEnd(LocalDate cycleStart) {
    LocalDate result = null;//from   www  . j  a  v  a 2s . c o  m
    if (frequency.equals(Frequency.W)) {
        result = cycleStart.plusDays(6);

    } else if (frequency.equals(Frequency.F)) {
        result = cycleStart.plusDays(13);

    } else if (frequency.equals(Frequency.SM)) {
        result = (cycleStart.getDayOfMonth() == 1) ? cycleStart.withDayOfMonth(15)
                : cycleStart.dayOfMonth().withMaximumValue();

    } else if (frequency.equals(Frequency.CM)) {
        result = cycleStart.dayOfMonth().withMaximumValue();

    } else if (frequency.equals(Frequency.Q)) {
        result = cycleStart.plusMonths(2).dayOfMonth().withMaximumValue();
    }
    return result;
}

From source file:dao.RegistroDao.java

public List<Registro> getListBetween(Date dt1, Date dt2) {
    List<Registro> result = new ArrayList<Registro>();
    try {//from  w  ww . j av  a  2s .co  m
        LocalDate dtTmp = LocalDate.fromDateFields(dt1);
        while (dt2.compareTo(dtTmp.dayOfMonth().withMinimumValue().toDate()) >= 0) {
            List<Registro> listTmp = getListByMonth(dtTmp.toDate());
            if (listTmp != null) {
                result.addAll(listTmp);
                //ordena a lista 
                Collections.sort(result, regComparator);
            }
            dtTmp = dtTmp.plusMonths(1);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return result;
}

From source file:de.appsolve.padelcampus.admin.controller.bookings.AdminBookingsSettingsController.java

private CalendarConfig getDefaultCalendarConfig() {
    CalendarConfig calendarConfig = new CalendarConfig();
    LocalDate now = new LocalDate(Constants.DEFAULT_TIMEZONE);
    calendarConfig.setStartDate(now);//w w w. ja  va 2  s  . co m
    calendarConfig.setEndDate(now.plusMonths(1));
    calendarConfig.setHolidayKey(Constants.DEFAULT_HOLIDAY_KEY);
    calendarConfig.setStartTimeHour(Constants.BOOKING_DEFAULT_VALID_FROM_HOUR);
    calendarConfig.setStartTimeMinute(Constants.BOOKING_DEFAULT_VALID_FROM_MINUTE);
    calendarConfig.setEndTimeHour(Constants.BOOKING_DEFAULT_VALID_UNTIL_HOUR);
    calendarConfig.setEndTimeMinute(Constants.BOOKING_DEFAULT_VALID_UNTIL_MINUTE);
    calendarConfig.setMinDuration(Constants.BOOKING_DEFAULT_DURATION);
    calendarConfig.setMinInterval(Constants.BOOKING_DEFAULT_MIN_INTERVAL);
    return calendarConfig;
}