I took the liberty of rehearsing my file reading abilities (not something I do every day) and rehearsing the LocalDates that Rob mentions, and try the new 'var' from java 9.
Well it turned out to be a big struggle that took me hours, and I noticed a few things that I could not handle.
First of all my code:
The big problem, that took me hours to find out, was that:
gave an error: ldt could not be converted to LocalDateTime.
After a while, this worked:
Hmm, it worked, but not very intuitive...
But the biggest problem was yet to come.
I had copied all Marks String dates into a Notepad file and saved it as UTF-8 to disc.
Whatever I tried, I could not read them in as Strings. It was maddening.... I got the much saying error that the read in strings could not be parsed at index 0, although in the debugger they looked exactly as my typed in string.
Saving the file as ANSI did work, without any problem. You read it in with Files.lines(path) and although the API says that it then reads the file as UTF-8, it worked without a hiccup.
And lastly, something that took me also quite a while to solve (if I solved it)
The API for Files.lines (or readAllLines) rells that you are supposed to use a try-with-resources. Okay, but how?
Files.readAllLines returns a List<String>, and
gives an error, since a List does not implement AutoClosable.
So I resorted (see my code) to
Hmmm... this was an exercise not to be forgotten any time soon!
A shock for me: I thought I knew my way with LocalDates and Files, but now I'm standing with two legs on the ground again, as we say in Holland.
Can someone far more knowledgeable that me explain how this UTF thing works, and how to handle Files.xxx with try-with-rexources?