QuarterlyPeriod implements Period { @Override public Date getEndDate() { return endDate; } QuarterlyPeriod(Date date); @Override void setStartDate(Date startDate); @Override void setEndDate(Date endDate); @Override Date getStartDate(); @Override Date getEndDate(); @Override String getAsIsoString(); static final String ISO_FORMAT; }
@Test public void testGetEnd() throws ParseException { QuarterlyPeriod instance = new QuarterlyPeriod(new SimpleDateFormat( "yyyy-MM-dd").parse("2012-08-19")); Date expResult = new SimpleDateFormat("yyyy-MM-dd").parse("2012-10-01"); long time = expResult.getTime() - 1; expResult.setTime(time); Date result = instance.getEndDate(); assertEquals(expResult, result); }
@Test public void testGetEndLastQuarter() throws ParseException { QuarterlyPeriod instance = new QuarterlyPeriod(new SimpleDateFormat( "yyyy-MM-dd").parse("2012-10-19")); Date expResult = new SimpleDateFormat("yyyy-MM-dd").parse("2013-01-01"); long time = expResult.getTime() - 1; expResult.setTime(time); Date result = instance.getEndDate(); assertEquals(expResult, result); }