Here you can find the source of double2str(double amount, int length)
public static String double2str(double amount, int length)
//package com.java2s; //License from project: Open Source License public class Main { public static String double2str(double amount, int length) { String strAmt = Double.toString(amount); int pos = strAmt.indexOf('.'); if (pos != -1 && strAmt.length() > length + pos + 1) strAmt = strAmt.substring(0, pos + length + 1); return strAmt; }//from www. ja va 2 s.co m }