Here you can find the source of convertToPerHour(float speedInMetersPerSecond, boolean imperial)
public static String convertToPerHour(float speedInMetersPerSecond, boolean imperial)
//package com.java2s; //License from project: Open Source License public class Main { private static final float ratio = 1.609344f; public static String convertToPerHour(float speedInMetersPerSecond, boolean imperial) { float speedPerHour = speedInMetersPerSecond / 1000 * 60 * 60; if (imperial) { speedPerHour = speedPerHour / ratio; }//w ww .j a v a2s.c om return String.format("%02.02f", speedPerHour); } }