Parse String timestamp to Instant throws Unsupported field: InstantSeconds

A simpler method is to add the default timezone to the formatter object when declaring it

final DateTimeFormatter formatter = DateTimeFormatter
                                    .ofPattern("yyyy-MM-dd HH:mm:ss")
                                    .withZone(ZoneId.systemDefault());
Instant result = Instant.from(formatter.parse(timestamp));

Leave a Comment