How to measure the a time-span in seconds using System.currentTimeMillis()?

前端 未结 9 556
温柔的废话
温柔的废话 2020-12-02 10:09

How to convert System.currentTimeMillis(); to seconds?

long start6=System.currentTimeMillis();
System.out.println(counter.countPrimes(100000000)         


        
9条回答
  •  独厮守ぢ
    2020-12-02 10:14

    For conversion of milliseconds to seconds, since 1 second = 10³ milliseconds:

    //here m will be in seconds
    long m = System.currentTimeMillis()/1000;
    
    //here m will be in minutes
    long m = System.currentTimeMillis()/1000/60; //this will give in mins
    

提交回复
热议问题