List of utility methods to do Time Elapsed
boolean | elapsed(long duration, long required) Checks whether a certain amount of milliseconds have elapsed a given time in milliseconds. return System.currentTimeMillis() - duration >= required;
|
boolean | elapsed(long from, long required) Check if enough time has passed by from a certain moment. return System.currentTimeMillis() - from > required;
|
boolean | elapsed(long from, long to) elapsed return System.currentTimeMillis() - from >= to;
|
long | elapsedMicros(String startTime, String endTime) Gets elapsed millis from the times on the timeline return (long) ((new Double(endTime) - new Double(startTime)) * 1000); |
String | elapsedNanos(long nanoseconds) Returns a string representation of the specified elapsed time in the format "H hours M minutes S seconds". long seconds = Math.round(nanoseconds / 1000000000.0); StringBuilder sb = new StringBuilder(80); if (seconds >= 3600) { long hours = seconds / 3600; sb.append(hours); sb.append(hours == 1 ? " hour " : " hours "); seconds %= 3600; if (seconds >= 60) { long minutes = seconds / 60; sb.append(minutes); sb.append(minutes == 1 ? " minute " : " minutes "); seconds %= 60; sb.append(seconds); sb.append(seconds == 1 ? " second" : " seconds"); return sb.toString(); |
long | elapsedNanos(long startNanoTime) Nanoseconds elapsed since the time specified, the input is nanoTime the only conversion happens when computing the elapsed time. return System.nanoTime() - startNanoTime;
|
long | elapsedTime(long endTime, long beginTime) elapsed Time return endTime - beginTime;
|
String | elapsedTime(long milli) Formats a time interval in milliseconds to a String in the form "hours:minutes:seconds:millis" long seconds = milli / 1000; milli %= 1000; long minutes = seconds / 60; seconds %= 60; long hours = minutes / 60; minutes %= 60; return hours + "h " + minutes + "m " + seconds + "s " + milli; |
String | elapsedTime(long ms) elapsed Time String unit = "ms"; long value = ms; long rem = 0; if (ms >= 3600000) { unit = "h"; value = ms / 3600000; rem = ms % 3600000; } else if (ms >= 60000) { ... |
double | elapsedTime(long startTime, long endTime, double units) elapsed Time return (endTime - startTime) / units;
|