round double to Two Decimal - Java java.lang

Java examples for java.lang:double

Description

round double to Two Decimal

Demo Code


//package com.java2s;
import java.text.DecimalFormat;

public class Main {
    public static double roundTwoDec(double d) {
        DecimalFormat twoDForm = new DecimalFormat("#.##");
        return Double.valueOf(twoDForm.format(d));
    }/* w w w .  j a v a  2 s  .c o m*/
}

Related Tutorials