List of utility methods to do TimeUnit Calculate
boolean | sleepAndCachedInterruptedException(long sleepFor, TimeUnit unit) Sleep and cached InterruptedException. if (sleepFor <= 0) { return true; try { unit.sleep(sleepFor); return true; } catch (InterruptedException e) { return false; ... |
void | sleepFor(long period, TimeUnit timeUnit) This method is a convenience method for sleep that "swallows" InterruptedException and has TimeUnit parameter in addition to time period so it makes it very convenient. try { timeUnit.sleep(period); } catch (InterruptedException ie) { |
long | timeDiff(Calendar end, Calendar begin, TimeUnit timeUnit) time Diff long timeDiff = 0L; long diffMills = end.getTime().getTime() - begin.getTime().getTime(); switch (timeUnit) { case DAYS: timeDiff = diffMills / (1000 * 60 * 60 * 24); break; case HOURS: timeDiff = diffMills / (1000 * 60 * 60); ... |
long | timeDiff(Date date1, Date date2, TimeUnit minutes) time Diff return minutes.convert(date1.getTime() - date2.getTime(), TimeUnit.MILLISECONDS);
|
long | timeSince(final long startNanos, final TimeUnit destUnit) time Since return destUnit.convert(System.nanoTime() - startNanos, TimeUnit.NANOSECONDS);
|
void | waitForEnd(Process process, long timeout, TimeUnit unit) The same as calling Process#waitFor(long,TimeUnit) . process.waitFor(timeout, unit); |