Android Distance Readable Format distance(float distanceInKm, boolean imperial)

Here you can find the source of distance(float distanceInKm, boolean imperial)

Description

distance

License

Open Source License

Declaration

public static String distance(float distanceInKm, boolean imperial) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    private static final float ratio = 1.609344f;

    public static String distance(float distanceInKm, boolean imperial) {
        float distance = distanceInKm;
        if (imperial) {
            distance = distance / ratio;
        }//from www .j a  va 2 s. c om
        return String.format("%02.02f", distance);
    }
}

Related

  1. distanceToKM(double distance)
  2. distanceToMiles(double distance)
  3. durationToHourMinOrMinSec(long duration)