Reputation: 551
I want to do somthing like this:
Date startDate = new Date();
// Do Something
Date endDate = new Date();
double msElapsedTime =endDate.getTime()-startDate.getTime();
I have the result value in milisecond like this:7.0
but I want to have the exaxt value for example:7.15
How can I do that?
Upvotes: 2
Views: 93
Reputation: 784968
Using System.nanoTime():
long startTime = System.nanoTime()
// Do Something
long endTime = System.nanoTime();
// to get microsecond value
double msElapsedTime = ((double) (endTime - startTime)) / 1000.0;
Upvotes: 2