double decimal format - Java java.lang

Java examples for java.lang:double Format

Description

double decimal format

Demo Code


//package com.java2s;

import java.text.DecimalFormat;

public class Main {

    public static Double decimal(double b, int scale) {
        String format = "%1$." + scale + "f";
        DecimalFormat decimal = new DecimalFormat(
                String.format(format, 0.0));
        return new Double(decimal.format(b));
    }//from   www  . j a va 2 s . c  om
}

Related Tutorials