public UtcInstant convertToUtc(Instant instant) {
        long epochDay = Math.floorDiv(instant.getEpochSecond(), SECS_PER_DAY);
        long mjd = epochDay + OFFSET_MJD_EPOCH;
        long slsNanos = Math.floorMod(instant.getEpochSecond(), SECS_PER_DAY) * NANOS_PER_SECOND + instant.getNano();
        int leapAdj = getLeapSecondAdjustment(mjd);
        long startSlsNanos = (SECS_PER_DAY + leapAdj - 1000) * NANOS_PER_SECOND;
        long utcNanos = slsNanos;
        if (leapAdj != 0 && slsNanos >= startSlsNanos) {
            utcNanos = startSlsNanos + ((slsNanos - startSlsNanos) * 1000) / (1000 - leapAdj);  // apply UTC-SLS mapping
        }
        return UtcInstant.ofModifiedJulianDay(mjd, utcNanos);
    }
public UtcInstant convertToUtc ( Instant instant ) { long epochDay = Math . floorDiv ( instant . getEpochSecond ( ) , SECS_PER_DAY ) ; long mjd = epochDay + OFFSET_MJD_EPOCH ; long slsNanos = Math . floorMod ( instant . getEpochSecond ( ) , SECS_PER_DAY ) * NANOS_PER_SECOND + instant . getNano ( ) ; int leapAdj = getLeapSecondAdjustment ( mjd ) ; long startSlsNanos = ( SECS_PER_DAY + leapAdj - 1000 ) * NANOS_PER_SECOND ; long utcNanos = slsNanos ; if ( leapAdj != 0 && slsNanos >= startSlsNanos ) { utcNanos = startSlsNanos + ( ( slsNanos - startSlsNanos ) * 1000 ) / ( 1000 - leapAdj ) ; } return UtcInstant . ofModifiedJulianDay ( mjd , utcNanos ) ; }
Converts an {@code Instant} to a {@code UtcInstant}.
<p>
This method converts from an instant with 86400 subdivisions per day
to the UTC time-scale using the leap-second rules of the implementation.
<p>
The standard implementation uses the UTC-SLS algorithm.
Overriding this algorithm is possible, however doing so will conflict other parts
of the specification.
<p>
The algorithm calculates the UTC nanos-of-day {@code U} from the UTC-SLS nanos-of day {@code US}.<br>
Let {@code L = getLeapAdjustment(mjd)}.<br>
Let {@code B = 86400 + L - 1000}.<br>
Let {@code U = B + ((US - B) * 1000) / (1000 - L)}.<br>
Where the algorithm is applied while {@code US >= B}.<br>
(This algorithm has been tuned for integer arithmetic from the UTC-SLS specification.)

@param instant  the instant to convert, not null
@return the converted UTC instant, not null
@throws DateTimeException if the valid range is exceeded
@throws ArithmeticException if numeric overflow occurs