2

我想做这样的事情:

    Date startDate = new Date();
 // Do Something
    Date endDate = new Date();
    double msElapsedTime =endDate.getTime()-startDate.getTime();

我有这样的毫秒结果值:7.0但我想有 exaxt 值,例如:7.15

我怎样才能做到这一点?

4

1 回答 1

2

Using System.nanoTime():

long startTime = System.nanoTime()
// Do Something
long endTime = System.nanoTime();
// to get microsecond value
double msElapsedTime = ((double) (endTime - startTime)) / 1000.0;
于 2013-09-07T11:30:33.747 回答