SpeedFormatterUtil { public static int format(final double metersPerSecond, final UnitSystem system) { SpeedConverter speedConverter = new SpeedConverter(); Measurement speedMeterPerSecond = new Measurement(metersPerSecond, MeasurementUnit.METERS_PER_SECOND); double ret; switch (system) { case IMPERIAL_UK: case IMPERIAL_US: ret = speedConverter.convert(speedMeterPerSecond.getValue(), speedMeterPerSecond.getUnit(), MeasurementUnit.MILES_PER_HOUR).getValue(); break; case METRIC: default: ret = speedConverter.convert(speedMeterPerSecond.getValue(), speedMeterPerSecond.getUnit(), MeasurementUnit.KILOMETERS_PER_HOUR).getValue(); break; } return (int) Math.round(ret); } private  SpeedFormatterUtil(); static int format(final double metersPerSecond, final UnitSystem system); static String getUnitString(final Context context, final UnitSystem system);  }
@Test public void testFormat() { assertEquals( SpeedFormatterUtil.format(METERS_PER_SECOND_SPEED, UnitSystem.METRIC), (int) KILOMETERS_PER_HOUR_SPEED); assertEquals( SpeedFormatterUtil.format(METERS_PER_SECOND_SPEED, UnitSystem.IMPERIAL_UK), (int) MILES_PER_HOUR_SPEED); assertEquals( SpeedFormatterUtil.format(METERS_PER_SECOND_SPEED, UnitSystem.IMPERIAL_US), (int) MILES_PER_HOUR_SPEED); }