Here you can find the source of formatDecimals(double number)
public static String formatDecimals(double number)
//package com.java2s; //License from project: Open Source License import java.text.DecimalFormat; public class Main { public static String formatDecimals(long number) { return new DecimalFormat().format(number); }//w w w . j a v a 2 s . c o m public static String formatDecimals(long number, char separator) { return new DecimalFormat().format(number).replace(',', separator); } public static String formatDecimals(double number) { return new DecimalFormat().format(number); } public static String formatDecimals(double number, char separator) { return new DecimalFormat().format(number).replace(',', separator); } public static String replace(String source, String[] oldStrings, String[] newStrings) { if (oldStrings.length == newStrings.length) { for (int i = 0; i < newStrings.length; i++) { source = source.replace(oldStrings[i], newStrings[i]); } } return source; } }