Here you can find the source of formatTime(BigInteger femto)
public static String formatTime(BigInteger femto)
//package com.java2s; //License from project: Open Source License import java.math.BigInteger; public class Main { public static String formatTime(BigInteger femto) { if (femto.equals(BigInteger.ZERO)) return "0"; StringBuilder time = new StringBuilder(femto.toString()); String[] units = { "fs", "ps", "ns", "us", "ms", "sec", "ksec", "Msec" }; for (String unit : units) { if (time.length() <= 3 || !time.toString().endsWith("000")) return time + " " + unit; time.setLength(time.length() - 3); }/*from w w w . jav a2s. com*/ return time + " " + units[units.length - 1]; } }