QuarterlyPeriodType extends CalendarPeriodType { @Override public Date getRewindedDate( Date date, Integer rewindedPeriods ) { Calendar cal = getCalendar(); date = date != null ? date : new Date(); rewindedPeriods = rewindedPeriods != null ? rewindedPeriods : 1; DateTimeUnit dateTimeUnit = createLocalDateUnitInstance( date ); dateTimeUnit = cal.minusMonths( dateTimeUnit, rewindedPeriods * 3 ); return cal.toIso( dateTimeUnit ).toJdkDate(); }  @Override String getName(); @Override Period createPeriod( DateTimeUnit dateTimeUnit, Calendar calendar ); @Override int getFrequencyOrder(); @Override String getSqlInterval(); @Override DateTimeUnit getDateWithOffset( DateTimeUnit dateTimeUnit, int offset, Calendar calendar ); @Override List<Period> generatePeriods( DateTimeUnit dateTimeUnit ); @Override List<Period> generateRollingPeriods( Date date ); @Override List<Period> generateRollingPeriods( DateTimeUnit dateTimeUnit, Calendar calendar ); @Override String getIsoDate( DateTimeUnit dateTimeUnit, Calendar calendar ); @Override String getIsoFormat(); @Override String getIso8601Duration(); @Override Date getRewindedDate( Date date, Integer rewindedPeriods ); static final String NAME; static final int FREQUENCY_ORDER; static final String SQL_INTERVAL; }
@Test public void testGetRewindedDate() { assertEquals( new DateTime( 2020, 1, 15, 0, 0 ).toDate(), periodType.getRewindedDate( new DateTime( 2020, 10, 15, 0, 0 ).toDate(), 3 ) ); assertEquals( new DateTime( 2020, 7, 1, 0, 0 ).toDate(), periodType.getRewindedDate( new DateTime( 2020, 1, 1, 0, 0 ).toDate(), -2 ) ); }