Android examples for java.lang:Double
Convert decimal value To Percent
import java.text.DecimalFormat; public class Main { public static boolean emptyOrNull(String str) { return str == null || str.length() == 0; }/* ww w . jav a 2 s .co m*/ public static boolean emptyOrNull(String... arrStr) { for (String str : arrStr) { if (emptyOrNull(str)) { return true; } } return false; } public static String decimalToPercent(String decimal) { float value = -1; if (!emptyOrNull(decimal)) { try { value = Float.parseFloat(decimal); } catch (NumberFormatException e) { } } if (value == -1) { return ""; } else { DecimalFormat format = new DecimalFormat("0.#%"); return format.format(value); } } }