GlobAerosolReader extends AbstractProductReader { static ProductData.UTC calcEndTime(ProductData.UTC startDate, Period period) { final Calendar asCalendar = startDate.getAsCalendar(); asCalendar.add(period.getCalendarFieldIndex(), period.getAmount()); asCalendar.add(Calendar.SECOND, -1); return ProductData.UTC.create(asCalendar.getTime(), 0); } protected  GlobAerosolReader(GlobAerosolReaderPlugIn readerPlugIn); @Override void close();  }
@Test public void testEndTimeCalculation() throws ParseException { ProductData.UTC startTime = ProductData.UTC.parse("2010-05-26", GlobAerosolReader.UTC_DATE_PATTERN); ProductData.UTC endTime = GlobAerosolReader.calcEndTime(startTime, Period.DAILY); Calendar actualCalendar = endTime.getAsCalendar(); Calendar expectCal = ProductData.UTC.parse("2010-05-26 23:59:59", "yyyy-MM-dd HH:mm:ss").getAsCalendar(); assertEquals(expectCal, actualCalendar); startTime = ProductData.UTC.parse("2000-02-26", GlobAerosolReader.UTC_DATE_PATTERN); endTime = GlobAerosolReader.calcEndTime(startTime, Period.WEEKLY); expectCal = ProductData.UTC.parse("2000-03-03 23:59:59", "yyyy-MM-dd HH:mm:ss").getAsCalendar(); actualCalendar = endTime.getAsCalendar(); assertEquals(expectCal, actualCalendar); startTime = ProductData.UTC.parse("2000-02-01", GlobAerosolReader.UTC_DATE_PATTERN); endTime = GlobAerosolReader.calcEndTime(startTime, Period.MONTHLY); expectCal = ProductData.UTC.parse("2000-02-29 23:59:59", "yyyy-MM-dd HH:mm:ss").getAsCalendar(); actualCalendar = endTime.getAsCalendar(); assertEquals(expectCal, actualCalendar); startTime = ProductData.UTC.parse("2002-02-01", GlobAerosolReader.UTC_DATE_PATTERN); endTime = GlobAerosolReader.calcEndTime(startTime, Period.YEAR); expectCal = ProductData.UTC.parse("2003-01-31 23:59:59", "yyyy-MM-dd HH:mm:ss").getAsCalendar(); actualCalendar = endTime.getAsCalendar(); assertEquals(expectCal, actualCalendar); }