@Test public void shouldScaleNanosToMillis() { Double out = ExporterUtil.convertNanosTo(1.0, MetricUnits.MILLISECONDS); Assert.assertEquals(out, 0.000001, 1e-10); }
public static Double convertNanosTo(Double value, String unit) { Double out; switch (unit) { case MetricUnits.NANOSECONDS: out = value; break; case MetricUnits.MICROSECONDS: out = value / NANOS_PER_MICROSECOND; break; case MetricUnits.MILLISECONDS: out = value / NANOS_PER_MILLI; break; case MetricUnits.SECONDS: out = value / NANOS_PER_SECOND; break; case MetricUnits.MINUTES: out = value / NANOS_PER_MINUTE; break; case MetricUnits.HOURS: out = value / NANOS_PER_HOUR; break; case MetricUnits.DAYS: out = value / NANOS_PER_DAY; break; default: out = value; } return out; }
ExporterUtil { public static Double convertNanosTo(Double value, String unit) { Double out; switch (unit) { case MetricUnits.NANOSECONDS: out = value; break; case MetricUnits.MICROSECONDS: out = value / NANOS_PER_MICROSECOND; break; case MetricUnits.MILLISECONDS: out = value / NANOS_PER_MILLI; break; case MetricUnits.SECONDS: out = value / NANOS_PER_SECOND; break; case MetricUnits.MINUTES: out = value / NANOS_PER_MINUTE; break; case MetricUnits.HOURS: out = value / NANOS_PER_HOUR; break; case MetricUnits.DAYS: out = value / NANOS_PER_DAY; break; default: out = value; } return out; } }
ExporterUtil { public static Double convertNanosTo(Double value, String unit) { Double out; switch (unit) { case MetricUnits.NANOSECONDS: out = value; break; case MetricUnits.MICROSECONDS: out = value / NANOS_PER_MICROSECOND; break; case MetricUnits.MILLISECONDS: out = value / NANOS_PER_MILLI; break; case MetricUnits.SECONDS: out = value / NANOS_PER_SECOND; break; case MetricUnits.MINUTES: out = value / NANOS_PER_MINUTE; break; case MetricUnits.HOURS: out = value / NANOS_PER_HOUR; break; case MetricUnits.DAYS: out = value / NANOS_PER_DAY; break; default: out = value; } return out; } private  ExporterUtil(); }
ExporterUtil { public static Double convertNanosTo(Double value, String unit) { Double out; switch (unit) { case MetricUnits.NANOSECONDS: out = value; break; case MetricUnits.MICROSECONDS: out = value / NANOS_PER_MICROSECOND; break; case MetricUnits.MILLISECONDS: out = value / NANOS_PER_MILLI; break; case MetricUnits.SECONDS: out = value / NANOS_PER_SECOND; break; case MetricUnits.MINUTES: out = value / NANOS_PER_MINUTE; break; case MetricUnits.HOURS: out = value / NANOS_PER_HOUR; break; case MetricUnits.DAYS: out = value / NANOS_PER_DAY; break; default: out = value; } return out; } private  ExporterUtil(); static Double convertNanosTo(Double value, String unit); }
ExporterUtil { public static Double convertNanosTo(Double value, String unit) { Double out; switch (unit) { case MetricUnits.NANOSECONDS: out = value; break; case MetricUnits.MICROSECONDS: out = value / NANOS_PER_MICROSECOND; break; case MetricUnits.MILLISECONDS: out = value / NANOS_PER_MILLI; break; case MetricUnits.SECONDS: out = value / NANOS_PER_SECOND; break; case MetricUnits.MINUTES: out = value / NANOS_PER_MINUTE; break; case MetricUnits.HOURS: out = value / NANOS_PER_HOUR; break; case MetricUnits.DAYS: out = value / NANOS_PER_DAY; break; default: out = value; } return out; } private  ExporterUtil(); static Double convertNanosTo(Double value, String unit); static final long NANOS_PER_MICROSECOND; static final long NANOS_PER_MILLI; static final long NANOS_PER_SECOND; static final long NANOS_PER_MINUTE; static final long NANOS_PER_HOUR; static final long NANOS_PER_DAY; }