code: @SuppressWarnings("NarrowingCompoundAssignment")
    private static long normalizedDuration(long seconds, int nanos) {
      if (nanos <= -NANOS_PER_SECOND || nanos >= NANOS_PER_SECOND) {
        seconds = checkedAdd(seconds, nanos / NANOS_PER_SECOND);
        nanos %= NANOS_PER_SECOND;
      }
      if (seconds > 0 && nanos < 0) {
        nanos += NANOS_PER_SECOND; // no overflow since nanos is negative (and we're adding)
        seconds--; // no overflow since seconds is positive (and we're decrementing)
      }
      if (seconds < 0 && nanos > 0) {
        nanos -= NANOS_PER_SECOND; // no overflow since nanos is positive (and we're subtracting)
        seconds++; // no overflow since seconds is negative (and we're incrementing)
      }
      if (!durationIsValid(seconds, nanos)) {
        throw new IllegalArgumentException(String.format(
            "Duration is not valid. See proto definition for valid values. "
                + "Seconds (%s) must be in range [-315,576,000,000, +315,576,000,000]. "
                + "Nanos (%s) must be in range [-999,999,999, +999,999,999]. "
                + "Nanos must have the same sign as seconds", seconds, nanos));
      }
      return saturatedAdd(TimeUnit.SECONDS.toNanos(seconds), nanos);
    }
docs: Copy of {@link com.google.protobuf.util.Durations#normalizedDuration}.