format Distance - Android java.lang

Android examples for java.lang:Math

Description

format Distance

Demo Code


//package com.java2s;

import java.text.DecimalFormat;

public class Main {
    public static String formatDistance(double distance, String format) {
        DecimalFormat decimalFormat = new DecimalFormat(format);
        decimalFormat.setMinimumFractionDigits(2);
        decimalFormat.setMaximumFractionDigits(2);
        return decimalFormat.format(distance);
    }/*  w w w .  jav  a  2  s  .c  om*/
}

Related Tutorials