CellL3ProcessorMapper extends Mapper<LongWritable, L3TemporalBin, LongWritable, L3SpatialBin> { static double getMJD(String dateString) { if (dateString == null) { return 0; } Date date; try { date = DATE_FORMAT.parse(dateString); } catch (ParseException e) { CalvalusLogger.getLogger().log(Level.WARNING, "failed to parse date. " + e.getMessage(), e); return 0; } return ProductData.UTC.create(date, 0).getMJD(); }    }
@Test public void testGetMJD() throws Exception { assertEquals(1936.0, CellL3ProcessorMapper.getMJD("2005-04-20"), 1e-6); assertEquals(1937.0, CellL3ProcessorMapper.getMJD("2005-04-21"), 1e-6); assertEquals(0.0, CellL3ProcessorMapper.getMJD(null), 1e-6); }