示例#1
0
 /**
  * Obtains a {@code Duration} representing an amount in the specified unit.
  * <p>
  * The parameters represent the two parts of a phrase like '6 Hours'. For example:
  * <pre>
  *  Duration.of(3, SECONDS);
  *  Duration.of(465, HOURS);
  * </pre>
  * Only a subset of units are accepted by this method.
  * The unit must either have an {@linkplain TemporalUnit#isDurationEstimated() exact duration} or
  * be {@link ChronoUnit#DAYS} which is treated as 24 hours. Other units throw an exception.
  *
  * @param int $amount the amount of the duration, measured in terms of the unit, positive or negative
  * @param TemporalUnit $unit the unit that the duration is measured in, must have an exact duration, not null
  * @return Duration a {@code Duration}, not null
  * @throws DateTimeException if the period unit has an estimated duration
  * @throws ArithmeticException if a numeric overflow occurs
  */
 public static function of($amount, TemporalUnit $unit)
 {
     return self::$ZERO->plus($amount, $unit);
 }