System获取当前系统时间

xiaoxiao2021-02-27  664

public class SystemGetTimeDemo { public static void main(String[] args) throws InterruptedException { //获取当前系统时间与UTC1970年1月1日午夜时间的差 long startTime = System.currentTimeMillis();;//此为毫秒为单位 Thread.sleep(1000); long endTime = System.currentTimeMillis(); System.currentTimeMillis(); //时间差 System.out.println(endTime-startTime); long nanoTime = System.nanoTime();//此为纳秒为单位 System.out.println(nanoTime); } }
转载请注明原文地址: https://www.6miu.com/read-574.html

最新回复(0)