Round double value to Two Decimals - Android java.lang

Android examples for java.lang:Double

Description

Round double value to Two Decimals

Demo Code


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

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

Related Tutorials