Author: jlmonteiro Date: Tue Oct 15 20:30:19 2013 New Revision: 1532520 URL: http://svn.apache.org/r1532520 Log: Better rendering numbers in report plugin
Modified: commons/sandbox/monitoring/trunk/reporting/src/main/java/org/apache/commons/monitoring/reporting/web/plugin/report/format/MapFormat.java Modified: commons/sandbox/monitoring/trunk/reporting/src/main/java/org/apache/commons/monitoring/reporting/web/plugin/report/format/MapFormat.java URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/trunk/reporting/src/main/java/org/apache/commons/monitoring/reporting/web/plugin/report/format/MapFormat.java?rev=1532520&r1=1532519&r2=1532520&view=diff ============================================================================== --- commons/sandbox/monitoring/trunk/reporting/src/main/java/org/apache/commons/monitoring/reporting/web/plugin/report/format/MapFormat.java (original) +++ commons/sandbox/monitoring/trunk/reporting/src/main/java/org/apache/commons/monitoring/reporting/web/plugin/report/format/MapFormat.java Tue Oct 15 20:30:19 2013 @@ -21,6 +21,7 @@ import org.apache.commons.monitoring.cou import org.apache.commons.monitoring.counters.Unit; import org.apache.commons.monitoring.repositories.Repository; +import java.text.DecimalFormat; import java.util.ArrayList; import java.util.Collection; import java.util.Map; @@ -28,6 +29,7 @@ import java.util.concurrent.CopyOnWriteA public abstract class MapFormat { protected static final Collection<String> ATTRIBUTES_ORDERED_LIST = buildMetricDataHeader(); + private static final DecimalFormat NUMBER_FORMATTER = new DecimalFormat("###,###,###,##0.00###E0"); protected static Collection<String> buildMetricDataHeader() { final Collection<String> list = new CopyOnWriteArrayList<String>(); @@ -83,7 +85,11 @@ public abstract class MapFormat { if (md.isTime() && compatible && timeUnit != counterUnit) { value = timeUnit.convert(value, counterUnit); } - line.add(Double.toString(value)); + if (!Double.isNaN(value) && !Double.isInfinite(value)) { + line.add(NUMBER_FORMATTER.format(value)); + } else { + line.add(Double.toString(value)); + } } } return data;