CfTimePart extends ProfilePartIO { @Override public void decode(ProfileReadContext ctx, Product p) throws IOException { NetcdfFile ncFile = ctx.getNetcdfFile(); p.setStartTime( TimeUtils.getSceneRasterTime(ncFile, Constants.START_DATE_ATT_NAME, Constants.START_TIME_ATT_NAME)); p.setEndTime(TimeUtils.getSceneRasterTime(ncFile, Constants.STOP_DATE_ATT_NAME, Constants.STOP_TIME_ATT_NAME)); }  @Override void decode(ProfileReadContext ctx, Product p); @Override void preEncode(ProfileWriteContext ctx, Product p);  }
@Test public void testDecode_testfile_1() throws Exception { ctx = new TestProfileReadContext("../../../test.nc"); assertNull(product.getStartTime()); assertNull(product.getEndTime()); cfTimePart.decode(ctx, product); long expectedStartTime = ProductData.UTC.parse("2002-12-24 11:12:13", "yyyy-MM-dd HH:mm:ss").getAsDate().getTime(); long expectedEndTime = ProductData.UTC.parse("2002-12-24 11:12:14", "yyyy-MM-dd HH:mm:ss").getAsDate().getTime(); assertEquals(expectedStartTime, product.getStartTime().getAsDate().getTime()); assertEquals(expectedEndTime, product.getEndTime().getAsDate().getTime()); }
@Test public void testDecode_testfile_2() throws Exception { ctx = new TestProfileReadContext("../../../test_2.nc"); assertNull(product.getStartTime()); assertNull(product.getEndTime()); cfTimePart.decode(ctx, product); long expectedStartTime = ProductData.UTC.parse("2002-12-31 11:12:13", "yyyy-MM-dd HH:mm:ss").getAsDate().getTime(); long expectedEndTime = ProductData.UTC.parse("2002-12-31 22:12:14", "yyyy-MM-dd HH:mm:ss").getAsDate().getTime(); assertEquals(expectedStartTime, product.getStartTime().getAsDate().getTime()); assertEquals(expectedEndTime, product.getEndTime().getAsDate().getTime()); }