下面代码可以避免自己用难看的 System.currentMilliseconds 来计算执行时间。
import org.apache.commons.lang.time.StopWatch; StopWatch watch = new StopWatch(); watch.start(); /// some time consuming work watch.stop(); System.out.println("Total time:" + watch.toString());