Answer the question
In order to leave comments, you need to log in
What is the correct way to get the date from a string using java.time.*?
Hello!
There are lines like "some text dated 12/12/1990"
How to get this date correctly? whether to replace "." to "-" for that?
Thank you.
Answer the question
In order to leave comments, you need to log in
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd.MM.yyyy");
Stringdate = "12/12/1990";
LocalDate localDate = LocalDate.parse(date, formatter);
Parsing a string and extracting a date from it is a separate task, depending on the format. Regular expressions will help.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question