round double number by decimal Place - Android java.lang

Android examples for java.lang:Double

Description

round double number by decimal Place

Demo Code

import android.content.Context;
import android.graphics.Color;
import java.text.DecimalFormat;

public class Main{

    public static String round(double d, int decimalPlace) {
        DecimalFormat df = new DecimalFormat();
        df.setMaximumFractionDigits(decimalPlace);
        df.setMinimumFractionDigits(decimalPlace);
        return df.format(d);
    }// w w w .j av a  2s .  co  m

}

Related Tutorials