Here you can find the source of Rounding(double d, int i)
public static String Rounding(double d, int i)
//package com.java2s; //License from project: Apache License public class Main { public static String Rounding(double d, int i) { long a = (long) d; long b = (long) ((d - a) * Math.pow(10, i)); return a + "." + b; }//from w w w . ja va 2 s .com }