public long toEpochMilli() {
        if (seconds < 0 && nanos > 0) {
            long millis = Math.multiplyExact(seconds+1, 1000);
            long adjustment = nanos / 1000_000 - 1000;
            return Math.addExact(millis, adjustment);
        } else {
            long millis = Math.multiplyExact(seconds, 1000);
            return Math.addExact(millis, nanos / 1000_000);
        }
    }
public long toEpochMilli ( ) { if ( seconds < 0 && nanos > 0 ) { long millis = Math . multiplyExact ( seconds + 1 , 1000 ) ; long adjustment = nanos / 1000_000 - 1000 ; return Math . addExact ( millis , adjustment ) ; } else { long millis = Math . multiplyExact ( seconds , 1000 ) ; return Math . addExact ( millis , nanos / 1000_000 ) ; } }
Converts this instant to the number of milliseconds from the epoch
of 1970-01-01T00:00:00Z.
<p>
If this instant represents a point on the time-line too far in the future
or past to fit in a {@code long} milliseconds, then an exception is thrown.
<p>
If this instant has greater than millisecond precision, then the conversion
will drop any excess precision information as though the amount in nanoseconds
was subject to integer division by one million.

@return the number of milliseconds since the epoch of 1970-01-01T00:00:00Z
@throws ArithmeticException if numeric overflow occurs