Here you can find the source of formateNum(double num)
public static String formateNum(double num)
//package com.java2s; //License from project: Apache License import java.text.NumberFormat; public class Main { public static String formateNum(double num) { NumberFormat f = NumberFormat.getInstance(); f.setMaximumFractionDigits(4);//from www .jav a 2s.com return f.format(num); } }