获取系统当前时间:
package testQuartz.testSystem;
import java.util.Date;
public class SystemGetCurrentTime {
public static void main(String[] args) throws InterruptedException {
//获取当前系统时间与UTC1970年1月1日午夜时间的差
long startTime = System.currentTimeMillis();;//此为毫秒为单位
System.out.println("开始时间:" + startTime);
for(int i = 0; i < 1000000000; i++){
if(i == 999999999){
System.out.println("===========");
}
}
// Thread.sleep(1000);
long endTime = System.currentTimeMillis();
System.out.println("结束时间:" + endTime);
System.currentTimeMillis();
//转化成年月日
Date date = new Date(System.currentTimeMillis());
System.out.println(date);
//时间差
System.out.println("时间差:" + (endTime-startTime));
}
}
运行结果: