Parse nano seconds with less than 6 digits

Viewed 2131

I have the Timestamp 2017-07-25 16:19:59.89384

I want to parse it with:

DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSSSSS");
LocalDate time = LocalDateTime.parse(timeStamp, formatter);

But I get a DateTimeParseException because the nano seconds are only 5 digits. Is there a cleaner solution than padding 0's to the right?

2 Answers
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.n");
Related