Here you can find the source of formatDecNumber(Double number, String pattern)
public static final String formatDecNumber(Double number, String pattern)
//package com.java2s; //License from project: Open Source License import java.text.DecimalFormat; public class Main { public static final String NUMBER_PATTERN_1 = "####.0000"; public static final String formatDecNumber(Double number, String pattern) { DecimalFormat decimalFormat = new DecimalFormat(); decimalFormat.setDecimalSeparatorAlwaysShown(false); if (number == null) { number = 0.0;/*from w w w .j a v a 2 s. c o m*/ } if (pattern == null || "".equals(pattern)) { pattern = NUMBER_PATTERN_1; } else { decimalFormat.applyPattern(pattern); } return decimalFormat.format(number); } }