Java examples for java.text:DecimalFormat
get double Amount Format as 0.00
//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); } }