I am trying to create an object of the Java class LocalTime
like this:
LocalTime beginning = LocalTime.of(int hours, int minutes);
My problem is that I would like that my user could input the time in the following format: HH:MM However, when there's an input like 14:00 as String, I replace the ":" by "".
Then I say:
hours = Integer.parseInt(eingabe.substring(0, 2));
minutes = Integer.parseInt(eingabe.substring(2));
But now minutes is 0 and not 00 like I want it to.
I've done some research and found something like String.format("%02d", minutes)
, but the parameters of LocalTime.of()
needs to be integers.