Java Code Examples for java.time.LocalDate#plusMonths()

The following examples show how to use java.time.LocalDate#plusMonths() . 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: ScheduleGenerator.java    From finmath-lib with Apache License 2.0 6 votes vote down vote up
/**
 * Create a new date by "adding" a year fraction to the start date.
 * The year fraction is interpreted in a 30/360 way. More specifically,
 * every integer unit advances by a year, each remaining fraction of 12
 * advances by a month and each remaining fraction of 30 advances a day.
 *
 * The function may be used to ease the creation of maturities in spreadsheets.
 *
 * @param baseDate The start date.
 * @param offsetYearFrac The year fraction in 30/360 to be used for adding to the start date.
 * @return A date corresponding the maturity.
 */
private static LocalDate createDateFromDateAndOffset(final LocalDate baseDate, double offsetYearFrac) {

	// Years
	LocalDate maturity = baseDate.plusYears((int)offsetYearFrac);

	// Months
	offsetYearFrac = (offsetYearFrac - (int)offsetYearFrac) * 12;
	maturity = maturity.plusMonths((int)offsetYearFrac);

	// Days
	offsetYearFrac = (offsetYearFrac - (int)offsetYearFrac) * 30;
	maturity = maturity.plusDays((int)Math.round(offsetYearFrac));

	return maturity;
}
 
Example 2
Source File: DataTableBasic.java    From finmath-lib with Apache License 2.0 6 votes vote down vote up
private LocalDate dateFromOffset(final LocalDate startDate, final int offset) {
	LocalDate date = null;
	switch(convention) {
	case YEARS:
		date = startDate.plusYears(offset);
		break;
	case MONTHS:
		date = startDate.plusMonths(offset);
		break;
	case DAYS:
		date = startDate.plusDays(offset);
		break;
	case WEEKS:
		date = startDate.plusWeeks(offset);
		break;
	default:
		throw new IllegalArgumentException("Unknown convention " + convention + ".");
	}
	return date;
}
 
Example 3
Source File: ScheduleGenerator.java    From finmath-lib with Apache License 2.0 6 votes vote down vote up
/**
 * Create a new date by "adding" a year fraction to the start date.
 * The year fraction is interpreted in a 30/360 way. More specifically,
 * every integer unit advances by a year, each remaining fraction of 12
 * advances by a month and each remaining fraction of 30 advances a day.
 *
 * The function may be used to ease the creation of maturities in spreadsheets.
 *
 * @param baseDate The start date.
 * @param offsetYearFrac The year fraction in 30/360 to be used for adding to the start date.
 * @return A date corresponding the maturity.
 */
private static LocalDate createDateFromDateAndOffset(final LocalDate baseDate, double offsetYearFrac) {

	// Years
	LocalDate maturity = baseDate.plusYears((int)offsetYearFrac);

	// Months
	offsetYearFrac = (offsetYearFrac - (int)offsetYearFrac) * 12;
	maturity = maturity.plusMonths((int)offsetYearFrac);

	// Days
	offsetYearFrac = (offsetYearFrac - (int)offsetYearFrac) * 30;
	maturity = maturity.plusDays((int)Math.round(offsetYearFrac));

	return maturity;
}
 
Example 4
Source File: SABRVolatilityCubeSharedParametersTest.java    From finmath-lib with Apache License 2.0 5 votes vote down vote up
@Test
public void a_cubeATM() {

	final ArrayList<Integer> maturities			= new ArrayList<>();
	final ArrayList<Integer> terminations			= new ArrayList<>();
	final ArrayList<Double> volatilitiesModel		= new ArrayList<>();
	final ArrayList<Double> volatilitiesMarket	= new ArrayList<>();

	for(final int maturity : physicalVolatilities.getMaturities(0)) {
		for(final int termination : physicalVolatilities.getTenors(0, maturity)) {

			final LocalDate maturityDate = referenceDate.plusMonths(maturity);
			final LocalDate terminationDate = maturityDate.plusMonths(termination);

			final Schedule floatSchedule = floatMetaSchedule.generateSchedule(referenceDate, maturityDate, terminationDate);
			final Schedule fixSchedule = fixMetaSchedule.generateSchedule(referenceDate, maturityDate, terminationDate);
			final double swapRate = Swap.getForwardSwapRate(fixSchedule, floatSchedule, model.getForwardCurve(forwardCurveName), model);

			try {
				final double volatility = cube.getValue(model, fixSchedule.getPayment(fixSchedule.getNumberOfPeriods()-1), fixSchedule.getFixing(0), swapRate,
						QuotingConvention.VOLATILITYNORMAL);
				maturities.add(maturity);
				terminations.add(termination);
				volatilitiesModel.add(volatility);
				volatilitiesMarket.add(physicalVolatilities.getValue(maturity, termination, 0));
			} catch (final Exception e) {
				maturities.add(maturity);
				terminations.add(termination);
				volatilitiesModel.add(0.0);
				volatilitiesMarket.add(physicalVolatilities.getValue(maturity, termination, 0));
			}
		}
	}

	final DataTableLight modelTable	= new DataTableLight("Volatilites-Model", TableConvention.MONTHS, maturities, terminations, volatilitiesModel);
	final DataTableLight marketTable	= new DataTableLight("Volatilites-Market", TableConvention.MONTHS, maturities, terminations, volatilitiesMarket);
	output.append(marketTable.toString()+"\n");
	output.append("\n"+modelTable.toString()+"\n\n\n\n");

}
 
Example 5
Source File: SABRShiftedSmileCalibration.java    From finmath-lib with Apache License 2.0 5 votes vote down vote up
/**
 * Construct the volatility (half-) smile of cash settled payer swaptions.
 */
private void findPayerVolatilities() {

	//convert to volatilities
	cashPayerVolatilities = new TreeMap<>();
	for(final int moneyness : cashPayerPremiums.getGridNodesPerMoneyness().keySet()) {

		final ArrayList<Integer> maturities = new ArrayList<>();
		final ArrayList<Integer> terminations = new ArrayList<>();
		final ArrayList<Double> values = new ArrayList<>();

		for(final int maturity : interpolationNodes.getMaturities()) {
			for(final int termination : interpolationNodes.getTerminationsForMaturity(maturity)) {
				if(cashPayerPremiums.containsEntryFor(maturity, termination, moneyness)){

					final LocalDate maturityDate = referenceDate.plusMonths(maturity);
					final LocalDate terminationDate = maturityDate.plusMonths(termination);

					final Schedule fixSchedule = fixMetaSchedule.generateSchedule(referenceDate, maturityDate, terminationDate);
					final double swapRate = swapRateTable.getValue(maturity, termination);
					final double cashAnnuity = cashFunction(swapRate, fixSchedule);

					maturities.add(maturity);
					terminations.add(termination);
					values.add(AnalyticFormulas.bachelierOptionImpliedVolatility(swapRate, fixSchedule.getFixing(0), swapRate + moneyness /10000.0,
							cashAnnuity, cashPayerPremiums.getValue(maturity, termination, moneyness)));
				}
			}
		}
		final DataTableLight volatilityTable = new DataTableLight("VolatilitiesPayer"+moneyness, TableConvention.MONTHS, maturities, terminations, values);
		cashPayerVolatilities.put(moneyness, volatilityTable);
	}

}
 
Example 6
Source File: YearServiceImpl.java    From axelor-open-suite with GNU Affero General Public License v3.0 5 votes vote down vote up
public List<Period> generatePeriods(Year year) throws AxelorException {

    List<Period> periods = new ArrayList<Period>();
    Integer duration = year.getPeriodDurationSelect();
    LocalDate fromDate = year.getFromDate();
    LocalDate toDate = year.getToDate();
    LocalDate periodToDate = fromDate;
    Integer periodNumber = 1;
    int c = 0;
    int loopLimit = 1000;
    while (periodToDate.isBefore(toDate)) {
      if (periodNumber != 1) fromDate = fromDate.plusMonths(duration);
      if (c >= loopLimit) {
        throw new AxelorException(
            TraceBackRepository.CATEGORY_INCONSISTENCY, I18n.get(IExceptionMessage.PERIOD_3));
      }
      c += 1;
      periodToDate = fromDate.plusMonths(duration).minusDays(1);
      if (periodToDate.isAfter(toDate)) periodToDate = toDate;
      if (fromDate.isAfter(toDate)) continue;
      Period period = new Period();
      period.setFromDate(fromDate);
      period.setToDate(periodToDate);
      period.setYear(year);
      period.setName(String.format("%02d", periodNumber) + "/" + year.getCode());
      period.setCode(
          (String.format("%02d", periodNumber)
                  + "/"
                  + year.getCode()
                  + "_"
                  + year.getCompany().getCode())
              .toUpperCase());
      period.setStatusSelect(year.getStatusSelect());
      periods.add(period);
      periodNumber++;
    }
    return periods;
  }
 
Example 7
Source File: DateFiltersTest.java    From tablesaw with Apache License 2.0 4 votes vote down vote up
@Test
public void testGetMonthValue() {
  LocalDate date = LocalDate.of(2015, 1, 25);
  Month[] months = Month.values();

  DateColumn dateColumn = DateColumn.create("test");
  for (int i = 0; i < months.length; i++) {
    dateColumn.append(date);
    date = date.plusMonths(1);
  }

  StringColumn month = dateColumn.month();
  IntColumn monthValue = dateColumn.monthValue();

  for (int i = 0; i < months.length; i++) {
    assertEquals(months[i].name(), month.get(i).toUpperCase());
    assertEquals(i + 1, monthValue.get(i), 0.001);
  }

  assertTrue(dateColumn.isInJanuary().contains(0));
  assertTrue(dateColumn.isInFebruary().contains(1));
  assertTrue(dateColumn.isInMarch().contains(2));
  assertTrue(dateColumn.isInApril().contains(3));
  assertTrue(dateColumn.isInMay().contains(4));
  assertTrue(dateColumn.isInJune().contains(5));
  assertTrue(dateColumn.isInJuly().contains(6));
  assertTrue(dateColumn.isInAugust().contains(7));
  assertTrue(dateColumn.isInSeptember().contains(8));
  assertTrue(dateColumn.isInOctober().contains(9));
  assertTrue(dateColumn.isInNovember().contains(10));
  assertTrue(dateColumn.isInDecember().contains(11));

  assertTrue(dateColumn.isInQ1().contains(2));
  assertTrue(dateColumn.isInQ2().contains(4));
  assertTrue(dateColumn.isInQ3().contains(8));
  assertTrue(dateColumn.isInQ4().contains(11));

  Table t = Table.create("Test");
  t.addColumns(dateColumn);
  IntColumn index = IntColumn.indexColumn("index", t.rowCount(), 0);
  t.addColumns(index);

  assertTrue(t.where(t.dateColumn("test").isInJanuary()).intColumn("index").contains(0));
  assertTrue(t.where(t.dateColumn("test").isInFebruary()).intColumn("index").contains(1));
  assertTrue(t.where(t.dateColumn("test").isInMarch()).intColumn("index").contains(2));
  assertTrue(t.where(t.dateColumn("test").isInApril()).intColumn("index").contains(3));
  assertTrue(t.where(t.dateColumn("test").isInMay()).intColumn("index").contains(4));
  assertTrue(t.where(t.dateColumn("test").isInJune()).intColumn("index").contains(5));
  assertTrue(t.where(t.dateColumn("test").isInJuly()).intColumn("index").contains(6));
  assertTrue(t.where(t.dateColumn("test").isInAugust()).intColumn("index").contains(7));
  assertTrue(t.where(t.dateColumn("test").isInSeptember()).intColumn("index").contains(8));
  assertTrue(t.where(t.dateColumn("test").isInOctober()).intColumn("index").contains(9));
  assertTrue(t.where(t.dateColumn("test").isInNovember()).intColumn("index").contains(10));
  assertTrue(t.where(t.dateColumn("test").isInDecember()).intColumn("index").contains(11));

  assertTrue(t.where(t.dateColumn("test").isInQ1()).intColumn("index").contains(2));
  assertTrue(t.where(t.dateColumn("test").isInQ2()).intColumn("index").contains(4));
  assertTrue(t.where(t.dateColumn("test").isInQ3()).intColumn("index").contains(8));
  assertTrue(t.where(t.dateColumn("test").isInQ4()).intColumn("index").contains(11));
}
 
Example 8
Source File: TCKLocalDate.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
@Test(expectedExceptions=DateTimeException.class)
public void test_plusMonths_long_invalidTooLargeMaxAddMax() {
    LocalDate test = LocalDate.of(Year.MAX_VALUE, 12, 1);
    test.plusMonths(Long.MAX_VALUE);
}
 
Example 9
Source File: TCKLocalDate.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
@Test(expectedExceptions=DateTimeException.class)
public void test_plusMonths_long_invalidTooLargeMaxAddMin() {
    LocalDate test = LocalDate.of(Year.MAX_VALUE, 12, 1);
    test.plusMonths(Long.MIN_VALUE);
}
 
Example 10
Source File: TCKLocalDate.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
@Test(expectedExceptions=DateTimeException.class)
public void test_plusMonths_long_invalidTooLargeMaxAddMin() {
    LocalDate test = LocalDate.of(Year.MAX_VALUE, 12, 1);
    test.plusMonths(Long.MIN_VALUE);
}
 
Example 11
Source File: TCKLocalDate.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
@Test(expectedExceptions=DateTimeException.class)
public void test_plusMonths_long_invalidTooLargeMaxAddMin() {
    LocalDate test = LocalDate.of(Year.MAX_VALUE, 12, 1);
    test.plusMonths(Long.MIN_VALUE);
}
 
Example 12
Source File: TCKLocalDate.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
@Test(expectedExceptions=DateTimeException.class)
public void test_plusMonths_long_invalidTooLargeMaxAddMin() {
    LocalDate test = LocalDate.of(Year.MAX_VALUE, 12, 1);
    test.plusMonths(Long.MIN_VALUE);
}
 
Example 13
Source File: TCKLocalDate.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
@Test(expectedExceptions=DateTimeException.class)
public void test_plusMonths_long_invalidTooLargeMaxAddMax() {
    LocalDate test = LocalDate.of(Year.MAX_VALUE, 12, 1);
    test.plusMonths(Long.MAX_VALUE);
}
 
Example 14
Source File: TCKLocalDate.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
@Test(expectedExceptions=DateTimeException.class)
public void test_plusMonths_long_invalidTooLargeMaxAddMin() {
    LocalDate test = LocalDate.of(Year.MAX_VALUE, 12, 1);
    test.plusMonths(Long.MIN_VALUE);
}
 
Example 15
Source File: TCKLocalDate.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
@Test(expectedExceptions=DateTimeException.class)
public void test_plusMonths_long_invalidTooLargeMaxAddMin() {
    LocalDate test = LocalDate.of(Year.MAX_VALUE, 12, 1);
    test.plusMonths(Long.MIN_VALUE);
}
 
Example 16
Source File: SABRVolatilityCubeTest.java    From finmath-lib with Apache License 2.0 4 votes vote down vote up
@Test
public void a_cubeATM() {

	System.out.println("Testing cube at atm level...");

	final ArrayList<Integer> maturities			= new ArrayList<>();
	final ArrayList<Integer> terminations			= new ArrayList<>();
	final ArrayList<Double> volatilitiesModel		= new ArrayList<>();
	final ArrayList<Double> volatilitiesMarket	= new ArrayList<>();

	for(final int maturity : physicalVolatilities.getMaturities(0)) {
		for(final int termination : physicalVolatilities.getTenors(0, maturity)) {

			final LocalDate maturityDate = referenceDate.plusMonths(maturity);
			final LocalDate terminationDate = maturityDate.plusMonths(termination);

			final Schedule floatSchedule = floatMetaSchedule.generateSchedule(referenceDate, maturityDate, terminationDate);
			final Schedule fixSchedule = fixMetaSchedule.generateSchedule(referenceDate, maturityDate, terminationDate);
			final double swapRate = Swap.getForwardSwapRate(fixSchedule, floatSchedule, model.getForwardCurve(forwardCurveName), model);

			try {
				final double volatility = cube.getValue(model, fixSchedule.getPayment(fixSchedule.getNumberOfPeriods()-1), fixSchedule.getFixing(0), swapRate,
						QuotingConvention.VOLATILITYNORMAL);
				maturities.add(maturity);
				terminations.add(termination);
				volatilitiesModel.add(volatility);
				volatilitiesMarket.add(physicalVolatilities.getValue(maturity, termination, 0));
			} catch (final Exception e) {
				maturities.add(maturity);
				terminations.add(termination);
				volatilitiesModel.add(0.0);
				volatilitiesMarket.add(physicalVolatilities.getValue(maturity, termination, 0));
			}
		}
	}

	final DataTableLight modelTable	= new DataTableLight("Volatilites-Model", TableConvention.MONTHS, maturities, terminations, volatilitiesModel);
	final DataTableLight marketTable	= new DataTableLight("Volatilites-Market", TableConvention.MONTHS, maturities, terminations, volatilitiesMarket);
	output.append(marketTable.toString()+"\n");
	output.append("\n"+modelTable.toString()+"\n\n\n\n");

}
 
Example 17
Source File: ExecutionQueryTest.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
@Test
@Deployment(resources = { "org/flowable/engine/test/api/oneTaskProcess.bpmn20.xml" })
public void testQueryLocalDateVariable() throws Exception {
    Map<String, Object> vars = new HashMap<>();
    LocalDate localDate = LocalDate.now();
    vars.put("localDateVar", localDate);

    ProcessInstance processInstance1 = runtimeService.startProcessInstanceByKey("oneTaskProcess", vars);

    LocalDate localDate2 = localDate.plusDays(1);
    vars = new HashMap<>();
    vars.put("localDateVar", localDate);
    vars.put("localDateVar2", localDate2);
    ProcessInstance processInstance2 = runtimeService.startProcessInstanceByKey("oneTaskProcess", vars);

    LocalDate nextYear = localDate.plusYears(1);
    vars = new HashMap<>();
    vars.put("localDateVar", nextYear);
    ProcessInstance processInstance3 = runtimeService.startProcessInstanceByKey("oneTaskProcess", vars);

    LocalDate nextMonth = localDate.plusMonths(1);

    LocalDate twoYearsLater = localDate.plusYears(2);

    LocalDate oneYearAgo = localDate.minusYears(1);

    // Query on single localDate variable, should result in 2 matches
    ExecutionQuery query = runtimeService.createExecutionQuery().variableValueEquals("localDateVar", localDate);
    List<Execution> executions = query.list();
    assertThat(executions).hasSize(2);

    // Query on two localDate variables, should result in single value
    query = runtimeService.createExecutionQuery().variableValueEquals("localDateVar", localDate).variableValueEquals("localDateVar2", localDate2);
    Execution execution = query.singleResult();
    assertThat(execution).isNotNull();
    assertThat(execution.getId()).isEqualTo(processInstance2.getId());

    // Query with unexisting variable value
    execution = runtimeService.createExecutionQuery().variableValueEquals("localDateVar", localDate.minusDays(1)).singleResult();
    assertThat(execution).isNull();

    // Test NOT_EQUALS
    execution = runtimeService.createExecutionQuery().variableValueNotEquals("localDateVar", localDate).singleResult();
    assertThat(execution).isNotNull();
    assertThat(execution.getId()).isEqualTo(processInstance3.getId());

    // Test GREATER_THAN
    execution = runtimeService.createExecutionQuery().variableValueGreaterThan("localDateVar", nextMonth).singleResult();
    assertThat(execution).isNotNull();
    assertThat(execution.getId()).isEqualTo(processInstance3.getId());

    assertThat(runtimeService.createExecutionQuery().variableValueGreaterThan("localDateVar", nextYear).count()).isZero();
    assertThat(runtimeService.createExecutionQuery().variableValueGreaterThan("localDateVar", oneYearAgo).count()).isEqualTo(3);

    // Test GREATER_THAN_OR_EQUAL
    execution = runtimeService.createExecutionQuery().variableValueGreaterThanOrEqual("localDateVar", nextMonth).singleResult();
    assertThat(execution).isNotNull();
    assertThat(execution.getId()).isEqualTo(processInstance3.getId());

    execution = runtimeService.createExecutionQuery().variableValueGreaterThanOrEqual("localDateVar", nextYear).singleResult();
    assertThat(execution).isNotNull();
    assertThat(execution.getId()).isEqualTo(processInstance3.getId());

    assertThat(runtimeService.createExecutionQuery().variableValueGreaterThanOrEqual("localDateVar", oneYearAgo).count()).isEqualTo(3);

    // Test LESS_THAN
    executions = runtimeService.createExecutionQuery().variableValueLessThan("localDateVar", nextYear).list();
    assertThat(executions)
        .extracting(Execution::getId)
        .containsExactlyInAnyOrder(
            processInstance1.getId(),
            processInstance2.getId()
        );

    assertThat(runtimeService.createExecutionQuery().variableValueLessThan("localDateVar", localDate).count()).isZero();
    assertThat(runtimeService.createExecutionQuery().variableValueLessThan("localDateVar", twoYearsLater).count()).isEqualTo(3);

    // Test LESS_THAN_OR_EQUAL
    executions = runtimeService.createExecutionQuery().variableValueLessThanOrEqual("localDateVar", nextYear).list();
    assertThat(executions).hasSize(3);

    assertThat(runtimeService.createExecutionQuery().variableValueLessThanOrEqual("localDateVar", oneYearAgo).count()).isZero();

    // Test value-only matching
    execution = runtimeService.createExecutionQuery().variableValueEquals(nextYear).singleResult();
    assertThat(execution).isNotNull();
    assertThat(execution.getId()).isEqualTo(processInstance3.getId());

    executions = runtimeService.createExecutionQuery().variableValueEquals(localDate).list();
    assertThat(executions)
        .extracting(Execution::getId)
        .containsExactlyInAnyOrder(
            processInstance1.getId(),
            processInstance2.getId()
        );

    execution = runtimeService.createExecutionQuery().variableValueEquals(twoYearsLater).singleResult();
    assertThat(execution).isNull();
}
 
Example 18
Source File: SABRVolatilityCubeTest.java    From finmath-lib with Apache License 2.0 4 votes vote down vote up
@Test
public void a_cubeATM() {

	System.out.println("Testing cube at atm level...");

	final ArrayList<Integer> maturities			= new ArrayList<>();
	final ArrayList<Integer> terminations			= new ArrayList<>();
	final ArrayList<Double> volatilitiesModel		= new ArrayList<>();
	final ArrayList<Double> volatilitiesMarket	= new ArrayList<>();

	for(final int maturity : physicalVolatilities.getMaturities(0)) {
		for(final int termination : physicalVolatilities.getTenors(0, maturity)) {

			final LocalDate maturityDate = referenceDate.plusMonths(maturity);
			final LocalDate terminationDate = maturityDate.plusMonths(termination);

			final Schedule floatSchedule = floatMetaSchedule.generateSchedule(referenceDate, maturityDate, terminationDate);
			final Schedule fixSchedule = fixMetaSchedule.generateSchedule(referenceDate, maturityDate, terminationDate);
			final double swapRate = Swap.getForwardSwapRate(fixSchedule, floatSchedule, model.getForwardCurve(forwardCurveName), model);

			try {
				final double volatility = cube.getValue(model, fixSchedule.getPayment(fixSchedule.getNumberOfPeriods()-1), fixSchedule.getFixing(0), swapRate,
						QuotingConvention.VOLATILITYNORMAL);
				maturities.add(maturity);
				terminations.add(termination);
				volatilitiesModel.add(volatility);
				volatilitiesMarket.add(physicalVolatilities.getValue(maturity, termination, 0));
			} catch (final Exception e) {
				maturities.add(maturity);
				terminations.add(termination);
				volatilitiesModel.add(0.0);
				volatilitiesMarket.add(physicalVolatilities.getValue(maturity, termination, 0));
			}
		}
	}

	final DataTableLight modelTable	= new DataTableLight("Volatilites-Model", TableConvention.MONTHS, maturities, terminations, volatilitiesModel);
	final DataTableLight marketTable	= new DataTableLight("Volatilites-Market", TableConvention.MONTHS, maturities, terminations, volatilitiesMarket);
	output.append(marketTable.toString()+"\n");
	output.append("\n"+modelTable.toString()+"\n\n\n\n");

}
 
Example 19
Source File: ForecastRecapService.java    From axelor-open-suite with GNU Affero General Public License v3.0 4 votes vote down vote up
public void populateWithSalaries(ForecastRecap forecastRecap) throws AxelorException {
  List<Employee> employeeList = new ArrayList<Employee>();
  ForecastRecapLineType salaryForecastRecapLineType =
      this.getForecastRecapLineType(ForecastRecapLineTypeRepository.ELEMENT_SALARY);
  if (forecastRecap.getBankDetails() != null) {
    employeeList =
        Beans.get(EmployeeRepository.class)
            .all()
            .filter(
                "self.mainEmploymentContract.payCompany = ?1 AND self.bankDetails = ?2",
                forecastRecap.getCompany(),
                forecastRecap.getBankDetails())
            .fetch();
  } else {
    employeeList =
        Beans.get(EmployeeRepository.class)
            .all()
            .filter("self.mainEmploymentContract.payCompany = ?1", forecastRecap.getCompany())
            .fetch();
  }
  LocalDate itDate =
      LocalDate.parse(forecastRecap.getFromDate().toString(), DateTimeFormatter.ISO_DATE);
  while (!itDate.isAfter(forecastRecap.getToDate())) {
    LocalDate monthEnd = itDate.withDayOfMonth(itDate.lengthOfMonth());
    if (itDate.isEqual(monthEnd)) {
      for (Employee employee : employeeList) {
        forecastRecap.addForecastRecapLineListItem(
            this.createForecastRecapLine(
                itDate,
                salaryForecastRecapLineType.getTypeSelect(),
                employee
                    .getHourlyRate()
                    .multiply(employee.getWeeklyWorkHours().multiply(new BigDecimal(4))),
                null,
                null,
                null,
                salaryForecastRecapLineType));
      }
      itDate = itDate.plusMonths(1);
    } else {
      itDate = monthEnd;
    }
  }
}
 
Example 20
Source File: TCKLocalDate.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
@Test(expectedExceptions=DateTimeException.class)
public void test_plusMonths_long_invalidTooLargeMaxAddMax() {
    LocalDate test = LocalDate.of(Year.MAX_VALUE, 12, 1);
    test.plusMonths(Long.MAX_VALUE);
}