Here you can find the source of computeSpeed(int distance, long duration)
Parameter | Description |
---|---|
distance | distance in meters |
duration | duration in milliseconds |
public static double computeSpeed(int distance, long duration)
//package com.java2s; import org.joda.time.DateTimeConstants; public class Main { /**/*w w w.ja v a2 s . c om*/ * Computes the average speed in km/h. * * @param distance distance in meters * @param duration duration in milliseconds * @return speed in km/h */ public static double computeSpeed(int distance, long duration) { return ((double) distance / 1000) / ((double) duration / DateTimeConstants.MILLIS_PER_HOUR); } }