【數(shù)據(jù)結(jié)構(gòu)與算法】美女講師帶你從0到1學(xué)數(shù)據(jù)結(jié)構(gòu)與算法
2022-07-20 16:32 作者:關(guān)阿姨的Java日記 | 我要投稿

計(jì)時(shí)工具自取哦,鐵子們!

package com;
import java.text.SimpleDateFormat;
import java.util.Date;
public class TimeTool {
??private static final SimpleDateFormat fmt=new SimpleDateFormat("HH:mm:ss.SSS");
??public interface Task{
????void execute();
??}
??public static void check(String title,Task task){
????if(task==null){
??????return;
????}
????title=(title==null)?"":("["+title+"]");
????System.out.println(title);
????System.out.println("開始:"+fmt.format(new Date()));
????long begin=System.currentTimeMillis();
????task.execute();
????long end=System.currentTimeMillis();
????System.out.println("結(jié)束:"+fmt.format(new Date()));
????double mill=(end-begin)/1000.0;
????System.out.println("耗時(shí):"+mill+"秒");
????System.out.println("------------");
??}
}
標(biāo)簽: