CsvStatisticsWriter implements StatisticsOutputter { static String getValueAsString(Number numberValue) { if (numberValue instanceof Float || numberValue instanceof Double) { return String.format(Locale.ENGLISH, "%.4f", numberValue.doubleValue()); } return numberValue.toString(); } CsvStatisticsWriter(PrintStream csvOutput); @Override void initialiseOutput(StatisticsOutputContext statisticsOutputContext); @Override void addToOutput(String bandName, String regionId, Map<String, Number> statistics); @Override void finaliseOutput();  }
@Test public void testGetValueAsString() throws Exception { assertEquals("0.0016", CsvStatisticsWriter.getValueAsString(1.6E-3)); assertEquals("10.0000", CsvStatisticsWriter.getValueAsString(10.0)); assertEquals("10", CsvStatisticsWriter.getValueAsString(10)); }