public static Instant parseInstant(final String string) {  // from TimestampSerDe
        if (string == null) {
            throw new NullPointerException("Instants.parseInstant receives only a non-null String.");
        }

        final Matcher matcher = INSTANT_PATTERN.matcher(string);
        if (!matcher.matches()) {
            throw new NumberFormatException("Instants.parseInstant received an invalid format: '" + string + "'");
        }

        // If the string matches INSTANT_PATTERN, all parsing below should be successful.
        // Any Exception would be considered as an unexpected error.

        final String integral;
        try {
            integral = matcher.group(1);
        } catch (final Exception ex) {
            throw new IllegalStateException("Unexpected error in retrieving the integral part of: '" + string + "'", ex);
        }

        final long epochSecond;
        try {
            epochSecond = LocalDateTime.parse(integral, INSTANT_FORMATTER_SECONDS).toEpochSecond(ZoneOffset.UTC);
        } catch (final Exception ex) {
            throw new IllegalStateException("Unexpected error in parsing: '" + integral + "'", ex);
        }

        final String fractional;
        try {
            fractional = matcher.group(2);
        } catch (final Exception ex) {
            throw new IllegalStateException("Unexpected error in retrieving the fractional part of: '" + string + "'", ex);
        }

        final int nanoAdjustment;
        if (fractional == null) {
            nanoAdjustment = 0;
        } else {
            try {
                nanoAdjustment = Integer.parseInt(fractional) * (int) Math.pow(10, 9 - fractional.length());
            } catch (final Exception ex) {
                throw new IllegalStateException("Unexpected error in parsing: '" + fractional + "'", ex);
            }
        }

        return Instant.ofEpochSecond(epochSecond, nanoAdjustment);
    }
Utility methods for {@code java.time.Instant}.

<p>Plugins should not use those methods directly.
embulk-core/src/main/java/org/embulk/spi/time/Instants.java