CalvalusProductIO { static void setDateToMerisSdrProduct(Product product, String pathName) throws IOException { try { int beginIndex = "CCI-Fire-MERIS-SDR-L3-300m-v1.0-".length(); int endIndex = beginIndex + 10; String timeString = pathName.substring(beginIndex, endIndex); ProductData.UTC day = ProductData.UTC.parse(timeString, "yyyy-MM-dd"); product.setStartTime(day); product.setEndTime(day); } catch (ParseException e) { throw new IOException(e); } }  static Product readProduct(Path path, Configuration conf, String inputFormat); static Product readProduct(PathConfiguration pathConf, String inputFormat); static File copyFileToLocal(Path path, Configuration conf); static File copyFileToLocal(Path path, File localFile, Configuration conf); static File[] uncompressArchiveToCWD(Path path, Configuration conf); static File[] uncompressArchiveToDir(Path path, File localDir, Configuration conf); static void printProductOnStdout(Product p, String origin);  }
@Test public void testSetDate() throws Exception { Product product = new Product("name", "type", 10, 10); CalvalusProductIO.setDateToMerisSdrProduct(product, "CCI-Fire-MERIS-SDR-L3-300m-v1.0-2008-12-07-v04h07.nc"); long expected = ProductData.UTC.parse("2008-12-07", "yyyy-MM-dd").getAsDate().getTime(); long actual = product.getStartTime().getAsDate().getTime(); assertEquals(expected, actual); }