获取程序执行所用时间

        //static long currentTimeMillis(),该方法返回值是从1970年1月1日凌晨到此时刻的毫秒数
        long startTime = System.currentTimeMillis();
        //<--
        //               代码块
        //                                   -->
        long endTime = System.currentTimeMillis();
        System.out.println("程序运行耗时: "+(endTime-startTime)+"ms");

猜你喜欢

转载自www.cnblogs.com/juanxincai/p/12321141.html