java计时器StopWatch


 请求接口时有时需要知道请求时间,所以用到stopwatch

导入jar包


            org.apache.commons
            commons-lang3
            3.3.2
        
public static void main(String[] args) {
    //创建并启动StopWatch
    StopWatch stopwatch = StopWatch.createStarted();
    try{
    //主体代码
    Thread.sleep(2000);
}finally{ stopwatch.stop(); }; System.out.println(stopwatch); }