on-internet
← Community

DateTimeParseException for LocalDateTime object despite having the format mapped

Stack Overflow ·

I have a Java 8 application that has to accept any number of date and time formats from a user. Obviously that yields an exhaustive list, as there are many ways to write a date and time. For locale purposes, though, this is all US-formatted dates (and yes, I checked that the locale was indeed en_US). However, what should be a simple date/time string has been causing a great deal of strife for me. Here is my code: String dateString = // user generated thing // Remove whitespace for simplicity's sake dateString = dateString.replaceAll("\\s+", ""); // There are A LOT of formats here, but I only p

Comments

Sign in or sign up to comment and upvote.

No comments yet.