Here you can find the source of formatAvgTime(double avg)
public static double formatAvgTime(double avg)
//package com.java2s; //License from project: Apache License import java.text.DecimalFormat; public class Main { public static double formatAvgTime(double avg) { // System.out.println("avg:" + avg + " totalMilliSeconds:" + // totalMilliSeconds + " totalCount:" + totalCount); String avgTime;//from www .j ava 2 s.c om if (avg < 0.01) { avgTime = new DecimalFormat(",000").format(avg); } else if (avg < 0.1) { avgTime = new DecimalFormat(",00").format(avg); } else { avgTime = new DecimalFormat(".").format(avg); } // String avgTime = new DecimalFormat(",###").format(avg); NumberUtil.format(avg, n); return Double.parseDouble(avgTime); } }