Here you can find the source of formatNumber(Number num)
public static String formatNumber(Number num)
//package com.java2s; //License from project: Open Source License import java.text.DecimalFormat; import java.text.DecimalFormatSymbols; public class Main { private static final String DEFAULT_NUMBER_FORMAT = "0.####"; public static String formatNumber(Number num, String pattern) { return num == null ? null : getDecimalFormat(pattern).format(num); }// w w w . j a v a2 s . c o m public static String formatNumber(Number num) { return formatNumber(num, DEFAULT_NUMBER_FORMAT); } public static DecimalFormat getDecimalFormat(String pattern) { DecimalFormatSymbols symbols = new DecimalFormatSymbols(); symbols.setDecimalSeparator('.'); DecimalFormat format = new DecimalFormat(pattern); format.setDecimalFormatSymbols(symbols); return format; } }