get double Amount Format as 0.00 - Java java.text

Java examples for java.text:DecimalFormat

Description

get double Amount Format as 0.00

Demo Code


//package com.java2s;

import java.text.DecimalFormat;

public class Main {
    public static void main(String[] argv) throws Exception {
        double num = 2.45678;
        System.out.println(getAmountFormat(num));
    }/*from   w ww .  j a  va 2 s.c  o  m*/

    public static String getAmountFormat(double num) {
        DecimalFormat dft = new DecimalFormat("0.00");
        return dft.format(num);
    }
}

Related Tutorials