System怎样获取当前系统时间

来源:互联网 发布:大学生就业知乎 编辑:程序博客网 时间:2024/05/29 10:35

获取系统当前时间:

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));}}

运行结果:







原创粉丝点击