core/play/src/main/java/play/libs/concurrent/DefaultFutures.java
@Override
  public <A> CompletionStage<A> timeout(
      final CompletionStage<A> stage, final long amount, final TimeUnit unit) {
    requireNonNull(stage, "Null stage");
    requireNonNull(unit, "Null unit");

    FiniteDuration duration = FiniteDuration.apply(amount, unit);
    return toJava(delegate.timeout(duration, Scala.asScalaWithFuture(() -> stage)));
  }
@Override
  public <A> CompletionStage<A> timeout(
      final CompletionStage<A> stage, final long amount, final TimeUnit unit) {
    requireNonNull(stage, "Null stage");
    requireNonNull(unit, "Null unit");

    FiniteDuration duration = FiniteDuration.apply(amount, unit);
    return toJava(delegate.timeout(duration, Scala.asScalaWithFuture(() -> stage)));
  }
Creates a CompletionStage that returns either the input stage, or a futures.

<p>Note that timeout is not the same as cancellation. Even in case of futures, the given
completion stage will still complete, even though that completed value is not returned.

@param stage the input completion stage that may time out.
@param amount The amount (expressed with the corresponding unit).
@param unit The time Unit.
@param <A> the completion's result type.
@return either the completed future, or a completion stage that failed with futures.