Java String format double type
public class Main { public static void main(String[] args) { double number = -12345.25f; String numberAsString = String.format ("%f", number); System.out.println(numberAsString); System.out.println(String.format ("%.1f", number)); System.out.println(String.format ("%.2f", number)); System.out.println(String.format ("%.3f", number)); /*from www. j ava2 s . com*/ } }