List of utility methods to do Distance Readable Format
String | distance(float distanceInKm, boolean imperial) distance float distance = distanceInKm; if (imperial) { distance = distance / ratio; return String.format("%02.02f", distance); |
String | distanceToKM(double distance) distance To KM return round(distance / 1000.0) + " km"; |
String | distanceToMiles(double distance) distance To Miles return round(distance * 0.000621371) + " mi"; |
String | durationToHourMinOrMinSec(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); ... |