Here you can find the source of getOneDecimalPercentFromDouble(double inValue)
Parameter | Description |
---|---|
inValue | a double value between 0 & 1 |
public static String getOneDecimalPercentFromDouble(double inValue)
//package com.java2s; //License from project: Open Source License import java.text.DecimalFormat; import java.text.DecimalFormatSymbols; import java.util.Locale; public class Main { /**/*from w w w .j a v a2 s . co m*/ * Return a percent value with 1 decimal value and the % at the end: 98.7% * used everywhere for example to show quality and reference evaluation values in the table * @param inValue a double value between 0 & 1 * @return */ public static String getOneDecimalPercentFromDouble(double inValue) { String shortString = ""; if (!(new Double(inValue)).isNaN()) { double d = inValue * 100; DecimalFormat oneDec = new DecimalFormat("0.0", new DecimalFormatSymbols(Locale.US)); shortString = (oneDec.format(d)); shortString += "%"; } else shortString = "0.0%"; return shortString; } }