Java examples for java.text:DecimalFormat
get Discount 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(getDiscountFormat(num)); }/*w w w.j av a2 s . c om*/ public static String getDiscountFormat(double num) { DecimalFormat dft = new DecimalFormat("0.00"); return dft.format(num); } }