@@ -0,0 +1,1660 @@
+/*%0A * Copyright (C) 2019 The Guava Authors%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22); you may not use this file except%0A * in compliance with the License. You may obtain a copy of the License at%0A *%0A * http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software distributed under the License%0A * is distributed on an %22AS IS%22 BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express%0A * or implied. See the License for the specific language governing permissions and limitations under%0A * the License.%0A */%0A%0Apackage com.google.common.util.concurrent;%0A%0Aimport com.google.common.annotations.GwtIncompatible;%0Aimport java.time.Duration;%0A%0A/** This class is for %7B@code com.google.common.util.concurrent%7D use only! */%0A@GwtIncompatible // java.time.Duration%0Afinal class Internal %7B%0A%0A  /**%0A   * Returns the number of nanoseconds of the given duration without throwing or overflowing.%0A   *%0A   * %3Cp%3EInstead of throwing %7B@link ArithmeticException%7D, this method silently saturates to either%0A   * %7B@link Long#MAX_VALUE%7D or %7B@link Long#MIN_VALUE%7D. This behavior can be useful when decomposing%0A   * a duration in order to call a legacy API which requires a %7B@code long, TimeUnit%7D pair.%0A   */%0A  static long saturatedToNanos(Duration duration) %7B%0A    // Using a try/catch seems lazy, but the catch block will rarely get invoked (except for%0A    // durations longer than approximately +/- 292 years).%0A    try %7B%0A      return duration.toNanos();%0A    %7D catch (ArithmeticException tooBig) %7B%0A      return duration.isNegative() ? Long.MIN_VALUE : Long.MAX_VALUE;%0A    %7D%0A  %7D%0A%0A  private Internal() %7B%7D%0A%7D%0A

Copy Durations.saturatedToNanos(Duration) to package-private c.g.c.u.c.Internal so it can be used by the concurrent package (and in Guava).