Android examples for java.text:DecimalFormat
Convert double to a string with correct separator and precision
//package com.java2s; import java.text.DecimalFormat; import java.text.DecimalFormatSymbols; public class Main { /**/*from w w w. java 2s . c om*/ * Convert double to a string with correct separator and precision * @param val - double to convert * @return */ public static String getStringDouble(Double val) { DecimalFormatSymbols df = new DecimalFormatSymbols(); df.setDecimalSeparator('.'); // Numeric keyboard has only point, so we // should use it DecimalFormat twoDigitsFormat = new DecimalFormat("#.##", df); return twoDigitsFormat.format(val); } }