Here you can find the source of formatDecimal(String format, double value)
public static String formatDecimal(String format, double value)
//package com.java2s; /*// w w w . j a va 2s .c om * PortUtil.cs * Copyright ? 2009-2011 kbinani * * This file is part of org.kbinani. * * org.kbinani is free software; you can redistribute it and/or * modify it under the terms of the BSD License. * * org.kbinani is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. */ import java.text.DecimalFormat; public class Main { public static String formatDecimal(String format, double value) { DecimalFormat df = new DecimalFormat(format); return df.format(value); } public static String formatDecimal(String format, long value) { DecimalFormat df = new DecimalFormat(format); return df.format(value); } }