Java Utililty Methods Duration Create

List of utility methods to do Duration Create

  1. HOME
  2. Java
  3. D
  4. Duration Create

Description

The list of methods to do Duration Create are organized into topic(s).

Method

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);

AltStyle によって変換されたページ (->オリジナル) /