driver-core/src/main/com/mongodb/operation/AggregateToCollectionOperation.java
public AggregateToCollectionOperation maxTime(final long maxTime, final TimeUnit timeUnit) {
        notNull("timeUnit", timeUnit);
        this.maxTimeMS = TimeUnit.MILLISECONDS.convert(maxTime, timeUnit);
        return this;
    }
public AggregateToCollectionOperation maxTime(final long maxTime, final TimeUnit timeUnit) {
        notNull("timeUnit", timeUnit);
        this.maxTimeMS = TimeUnit.MILLISECONDS.convert(maxTime, timeUnit);
        return this;
    }
Sets the maximum execution time on the server for this operation.

@param maxTime  the max time
@param timeUnit the time unit, which may not be null
@return this
@mongodb.driver.manual reference/method/cursor.maxTimeMS/#cursor.maxTimeMS Max Time