Java Code Examples for org.joda.time.LocalDate#minusYears()
The following examples show how to use
org.joda.time.LocalDate#minusYears() .
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: HrmaxRulesTest.java From qzr with Apache License 2.0 | 5 votes |
/** * If a date of birth is provided, then the rules should infer the person's * age. The inferred age is used in heart rate calculations later on. */ @Test public void shouldInferAge() { LocalDate today = new LocalDate(kieSession.getSessionClock().getCurrentTime()); LocalDate dob = today.minusYears(40); @SuppressWarnings("unused") FactHandle ageFact = kieSession.insert(new Known<>("dateOfBirth", dob)); kieSession.fireAllRules(); kieSession.getSessionClock().getCurrentTime(); assertTrue("Should infer age if date of birth is known.", hasKnownValue("age", 40)); }
Example 2
Source File: TurnoverAggregationService_Test.java From estatio with Apache License 2.0 | 4 votes |
@Test public void getTurnoversForAggregationPeriod_works() throws Exception { // given TurnoverAggregationService service = new TurnoverAggregationService(); final LocalDate aggregationDate = new LocalDate(2020, 1, 1); final AggregationPeriod aggregationPeriod = AggregationPeriod.P_2M; List<Turnover> turnovers = new ArrayList<>(); // when final Turnover turnoverThisYear = new Turnover(null, aggregationDate, null, null, null, null); final Turnover turnoverPlus1Month = new Turnover(null, aggregationDate.plusMonths(1), null, null, null, null); final Turnover turnoverMinus1Month = new Turnover(null, aggregationDate.minusMonths(1), null, null, null, null); turnovers.add(turnoverThisYear); turnovers.add(turnoverPlus1Month); turnovers.add(turnoverMinus1Month); // then Assertions.assertThat(service.getTurnoversForAggregationPeriod(aggregationPeriod, aggregationDate, turnovers, false)).hasSize(2); Assertions.assertThat(service.getTurnoversForAggregationPeriod(aggregationPeriod, aggregationDate, turnovers, false)).contains(turnoverThisYear); Assertions.assertThat(service.getTurnoversForAggregationPeriod(aggregationPeriod, aggregationDate, turnovers, false)).contains(turnoverMinus1Month); Assertions.assertThat(service.getTurnoversForAggregationPeriod(aggregationPeriod, aggregationDate, turnovers, false)).doesNotContain(turnoverPlus1Month); Assertions.assertThat(service.getTurnoversForAggregationPeriod(aggregationPeriod, aggregationDate, turnovers, true)).isEmpty(); // and when final Turnover turnoverPreviousYear = new Turnover(null, aggregationDate.minusYears(1), null, null, null, null); final Turnover turnoverPYPlus1Month = new Turnover(null, aggregationDate.minusYears(1).plusMonths(1), null, null, null, null); final Turnover turnoverPYMinus1Month = new Turnover(null, aggregationDate.minusYears(1).minusMonths(1), null, null, null, null); turnovers.add(turnoverPreviousYear); turnovers.add(turnoverPYPlus1Month); turnovers.add(turnoverPYMinus1Month); // then Assertions.assertThat(service.getTurnoversForAggregationPeriod(aggregationPeriod, aggregationDate, turnovers, false)).hasSize(2); Assertions.assertThat(service.getTurnoversForAggregationPeriod(aggregationPeriod, aggregationDate, turnovers, false)).contains(turnoverThisYear); Assertions.assertThat(service.getTurnoversForAggregationPeriod(aggregationPeriod, aggregationDate, turnovers, false)).contains(turnoverMinus1Month); Assertions.assertThat(service.getTurnoversForAggregationPeriod(aggregationPeriod, aggregationDate, turnovers, false)).doesNotContain(turnoverPlus1Month); Assertions.assertThat(service.getTurnoversForAggregationPeriod(aggregationPeriod, aggregationDate, turnovers, true)).hasSize(2); Assertions.assertThat(service.getTurnoversForAggregationPeriod(aggregationPeriod, aggregationDate, turnovers, true)).contains(turnoverPreviousYear); Assertions.assertThat(service.getTurnoversForAggregationPeriod(aggregationPeriod, aggregationDate, turnovers, true)).contains(turnoverPYMinus1Month); Assertions.assertThat(service.getTurnoversForAggregationPeriod(aggregationPeriod, aggregationDate, turnovers, true)).doesNotContain(turnoverPYPlus1Month); }
Example 3
Source File: DateUtil.java From activiti6-boot2 with Apache License 2.0 | 3 votes |
public static Date subtractDate(Date startDate, Integer years, Integer months, Integer days) { LocalDate currentDate = new LocalDate(startDate); currentDate = currentDate.minusYears(years); currentDate = currentDate.minusMonths(months); currentDate = currentDate.minusDays(days); return currentDate.toDate(); }
Example 4
Source File: DateUtil.java From flowable-engine with Apache License 2.0 | 3 votes |
public static Date subtractDate(Object startDate, Object years, Object months, Object days) { LocalDate currentDate = new LocalDate(startDate); currentDate = currentDate.minusYears(intValue(years)); currentDate = currentDate.minusMonths(intValue(months)); currentDate = currentDate.minusDays(intValue(days)); return currentDate.toDate(); }