This is an excerpt from the Scala Cookbook, 2nd Edition. This is Recipe 3.12, Parsing Strings Into Dates.
While using Scala (2 or 3), you need to parse a string into one of the date/time types introduced in Java 8.
If your string is in the expected format, pass it to the
parse method of the desired class. If the string is not in the expected (default) format, create a formatter to define the format you want to accept.