public CreateAssociationRequest withDuration(Integer duration) {
        setDuration(duration);
        return this;
    }
<p>
The number of hours the association can run before it is canceled. Duration applies to associations that are
currently running, and any pending and in progress commands on all targets. If a target was taken offline for the
association to run, it is made available again immediately, without a reboot.
</p>
<p>
The <code>Duration</code> parameter applies only when both these conditions are true:
</p>
<ul>
<li>
<p>
The association for which you specify a duration is cancelable according to the parameters of the SSM command
document or Automation runbook associated with this execution.
</p>
</li>
<li>
<p>
The command specifies the
<code> <a href="https://docs.aws.amazon.com/systems-manager/latest/APIReference/API_CreateAssociation.html#systemsmanager-CreateAssociation-request-ApplyOnlyAtCronInterval">ApplyOnlyAtCronInterval</a> </code>
parameter, which means that the association doesn't run immediately after it is created, but only according to
the specified schedule.
</p>
</li>
</ul>

@param duration
       The number of hours the association can run before it is canceled. Duration applies to associations that
       are currently running, and any pending and in progress commands on all targets. If a target was taken
       offline for the association to run, it is made available again immediately, without a reboot. </p>
       <p>
       The <code>Duration</code> parameter applies only when both these conditions are true:
       </p>
       <ul>
       <li>
       <p>
       The association for which you specify a duration is cancelable according to the parameters of the SSM
       command document or Automation runbook associated with this execution.
       </p>
       </li>
       <li>
       <p>
       The command specifies the
       <code> <a href="https://docs.aws.amazon.com/systems-manager/latest/APIReference/API_CreateAssociation.html#systemsmanager-CreateAssociation-request-ApplyOnlyAtCronInterval">ApplyOnlyAtCronInterval</a> </code>
       parameter, which means that the association doesn't run immediately after it is created, but only
       according to the specified schedule.
       </p>
       </li>
@return Returns a reference to this object so that method calls can be chained together.
aws-java-sdk-ssm/src/main/java/com/amazonaws/services/simplesystemsmanagement/model/CreateAssociationRequest.java