Code example for TimeUnit

Methods: convert

0
    this.time = time;
    this.unit = Precoditions.notNull(unit, "unit");
  } 
   
  public long getTime(TimeUnit unit) {
    return unit.convert(time, this.unit);
  } 
   
  public long getTimeInMillis() { 
    return getTime(TimeUnit.MILLISECONDS);
  } 
   
  @Override 
  public String toString() {
    return getClass().getSimpleName() + " (" + time + ", " + unit + ")";
  } 
}