List of utility methods to do Speed Readable Format
String | speedToKMH(double kmh) speed To KMH return round(kmh) + " km/h"; |
String | speedToMPH(double kmh) speed To MPH return round(kmh * 0.621) + " mph"; |
String | speedToPace(float speedInMetersPerSecond, boolean imperial) speed To Pace if (speedInMetersPerSecond <= 0) { return "0:00"; float speedPerHour = speedInMetersPerSecond / 1000 * 60 * 60; if (imperial) { speedPerHour = speedPerHour / ratio; float pacePerMinute = 60 / speedPerHour; ... |
float | convertSpeed(float speed, int fromScale, int toScale) convert a speed measurement from one scale to another switch (fromScale) { case KPH: switch (toScale) { case MPH: return convertFromKphToMph(speed); default: throw new IllegalArgumentException("invalid toScale"); case MPH: switch (toScale) { case KPH: return convertFromMphToKph(speed); default: throw new IllegalArgumentException("invalid toScale"); default: throw new IllegalArgumentException("invalid fromScale"); |