List of utility methods to do Duration Create
Duration | getDuration(final Date started, final Date finished) Get the duration between when something was started and finished. if (started == null || started.getTime() == 0) { return Duration.ZERO; } else if (finished == null || finished.getTime() == 0) { return Duration.ofMillis(new Date().getTime() - started.getTime()); } else { return Duration.ofMillis(finished.getTime() - started.getTime()); |
Duration | getDuration(Object o, TemporalUnit unit) get Duration if (o != null && o instanceof Duration) { return (Duration) o; try { return Duration.of(getLong(o), unit); } catch (IllegalArgumentException e) { throw new IllegalArgumentException("Don't know how to convert " + o + " to Duration", e); |