System.currentTimeMillis();
用这个取得当前时间System.currentTimeMillis();在程序的开始处取一下,然后在程序退出前再取一下,两次取得的值相减就是程序运行的时间,单位是毫秒。