Java examples for java.lang:double Format
Format an amount of money in double.
//package com.java2s; import java.text.DecimalFormat; public class Main { public static void main(String[] argv) { double amount = 42.45678; System.out.println(formatAmount(amount)); }/* w ww .j a v a 2 s . c om*/ /** * Format an amount of money. * @param amount Amount of money * @return */ public static String formatAmount(double amount) { return new DecimalFormat("0.00").format(amount); } }