private Timestamp addMillisForPrecision(long amount, Precision precision, boolean millisecondsPrecision) {
        // When millisecondsPrecision is true, the caller must do its own short-circuiting because it must
        // check the fractional precision.
        if (!millisecondsPrecision && amount == 0 && _precision == precision) return this;
        // This strips off the local offset, expressing our fields as if they
        // were UTC.
        BigDecimal millis = make_localtime().getDecimalMillis();
        millis = millis.add(BigDecimal.valueOf(amount));
        Precision newPrecision = _precision.includes(precision) ? _precision : precision;


        Timestamp ts = new Timestamp(millis, newPrecision, _offset);
        // Anything with courser-than-millis precision will have been extended
        // to 3 decimal places due to use of getDecimalMillis(). Compensate for
        // that by setting the scale such that it is never extended unless
        // milliseconds precision is being added and the fraction does not yet
        // have milliseconds precision.
        int newScale = millisecondsPrecision ? 3 : 0;
        if (_fraction != null) {
            newScale = Math.max(newScale, _fraction.scale());
        }
        if (ts._fraction != null) {
            ts._fraction = newScale == 0 ? null : ts._fraction.setScale(newScale, RoundingMode.FLOOR);
        }
        if (_offset != null && _offset != 0)
        {
            ts.apply_offset(_offset);
        }
        return ts;
    }
private Timestamp addMillisForPrecision ( long amount , Precision precision , boolean millisecondsPrecision ) { if ( ! millisecondsPrecision && amount == 0 && _precision == precision ) return this ; BigDecimal millis = make_localtime ( ) . getDecimalMillis ( ) ; millis = millis . add ( BigDecimal . valueOf ( amount ) ) ; Precision newPrecision = _precision . includes ( precision ) ? _precision : precision ; Timestamp ts = new Timestamp ( millis , newPrecision , _offset ) ; int newScale = millisecondsPrecision ? 3 : 0 ; if ( _fraction != null ) { newScale = Math . max ( newScale , _fraction . scale ( ) ) ; } if ( ts . _fraction != null ) { ts . _fraction = newScale == 0 ? null : ts . _fraction . setScale ( newScale , RoundingMode . FLOOR ) ; } if ( _offset != null && _offset != 0 ) { ts . apply_offset ( _offset ) ; } return ts ; }
Adds the given number of milliseconds, extending (if necessary) the resulting Timestamp to the given
precision.
@param amount the number of milliseconds to add.
@param precision the precision that the Timestamp will be extended to, if it does not already include that
precision.
@param millisecondsPrecision true if and only if the `amount` includes milliseconds precision. If true, the
resulting timestamp's fraction will have precision at least to the millisecond.
@return a new Timestamp.