计算两个时间戳的时间间隔

@Test
public void getTime() {
		
    long time1 = System.currentTimeMillis();
	System.out.println("time1="+time1);
	try {
		Thread.sleep((long) (Math.random()*1000*10));
	} catch (InterruptedException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
	long time2 = System.currentTimeMillis();
	System.out.println("time2="+time2);
	
        long l = (time2-time1)/(1000);
	System.out.println("l="+l);
		
}

 

你可能感兴趣的:(计算两个时间戳的时间间隔)