Here you can find the source of FormatDouble(double p_value, int p_numberOfDecimalPlaces)
static public String FormatDouble(double p_value, int p_numberOfDecimalPlaces)
//package com.java2s; /*/*from ww w . ja va2 s .c o m*/ Copyright 2016 Wes Kaylor This file is part of CoreUtil. CoreUtil is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. CoreUtil 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. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with CoreUtil. If not, see <http://www.gnu.org/licenses/>. */ public class Main { static public String FormatDouble(double p_value, int p_numberOfDecimalPlaces) { String t_valueString = Double.toString(p_value); if (t_valueString.contains(".")) { int t_decimalIndex = t_valueString.indexOf("."); if ((t_valueString.length() - (t_decimalIndex + 1)) > p_numberOfDecimalPlaces) { t_valueString = t_valueString.substring(0, (t_decimalIndex + (p_numberOfDecimalPlaces + 1))); } } return t_valueString; } }