public static String toString(final Instant instant) {
        if (instant == null) {
            throw new NullPointerException("Instants.toString receives only a non-null Instant.");
        }

        final int nano = instant.getNano();
        if (nano == 0) {
            return INSTANT_FORMATTER_SECONDS.format(instant) + " UTC";
        } else if (nano % 1000000 == 0) {
            return INSTANT_FORMATTER_MILLISECONDS.format(instant) + " UTC";
        } else {
            final StringBuilder builder = new StringBuilder();
            INSTANT_FORMATTER_SECONDS.formatTo(instant, builder);
            builder.append(".");

            final String digits;
            final int zeroDigits;
            if (nano % 1000 == 0) {
                digits = Integer.toString(nano / 1000);
                zeroDigits = 6 - digits.length();
            } else {
                digits = Integer.toString(nano);
                zeroDigits = 9 - digits.length();
            }
            builder.append(digits);
            for (int i = 0; i < zeroDigits; i++) {
                builder.append('0');
            }

            builder.append(" UTC");
            return builder.toString();
        }
    }
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