Android Utililty Methods Distance Readable Format

List of utility methods to do Distance Readable Format

Description

The list of methods to do Distance Readable Format are organized into topic(s).

Method

Stringdistance(float distanceInKm, boolean imperial)
distance
float distance = distanceInKm;
if (imperial) {
    distance = distance / ratio;
return String.format("%02.02f", distance);
StringdistanceToKM(double distance)
distance To KM
return round(distance / 1000.0) + " km";
StringdistanceToMiles(double distance)
distance To Miles
return round(distance * 0.000621371) + " mi";
StringdurationToHourMinOrMinSec(long duration)
duration To Hour Min Or Min Sec
String time = null;
long hours = TimeUnit.SECONDS.toHours(duration);
if (hours > 0) {
    long minutes = TimeUnit.SECONDS.toMinutes(duration
            - TimeUnit.HOURS.toSeconds(hours));
    time = String.format("%02d:%02d", hours, minutes);
} else {
    long minutes = TimeUnit.SECONDS.toMinutes(duration);
...