How do I calculate the elapsed time of an event in java? [duplicate]
问题 This question already has answers here : How do I time a method's execution in Java? (38 answers) Closed last year . What's a simple/easy way to access the system clock using Java, so that I can calculate the elapsed time of an event? 回答1: I would avoid using System.currentTimeMillis() for measuring elapsed time. currentTimeMillis() returns the 'wall-clock' time, which may change (eg: daylight savings, admin user changing the clock) and skew your interval measurements. System.nanoTime(), on