I want to take hours and minutes as input from user through a Combo box. I tried but i couldn't convert String into hours and minutes
Asked
Active
Viewed 265 times
-2
-
1*"I tried..."* what? Help us out so we don't go over the same ground and waste each other time – MadProgrammer Dec 04 '18 at 20:42
-
[`LocalTime.of(hour, minute)`](https://docs.oracle.com/javase/10/docs/api/java/time/LocalTime.html#of(int,int)) – MadProgrammer Dec 04 '18 at 20:44
-
1where is your code? – Reimeus Dec 04 '18 at 20:44
-
Possible duplicate [Coverting String to LocalTime with/without nanoOfSeconds](https://stackoverflow.com/questions/30788369/coverting-string-to-localtime-with-without-nanoofseconds); [How to convert a given time (String) to a LocalTime?](https://stackoverflow.com/questions/45595169/how-to-convert-a-given-time-string-to-a-localtime) – MadProgrammer Dec 04 '18 at 20:47
1 Answers
1
Just parse it using the Localtime static methods (See the jdk documentation about Time api). localTime.of(int, int)

midugh
- 608
- 5
- 21
-
1Seriously? [Why?](https://docs.oracle.com/javase/10/docs/api/java/time/LocalTime.html#of(int,int)) – MadProgrammer Dec 04 '18 at 20:43
-
1Agreed with @MadProgrammer - no point in teaching inexperienced users to use the old and largely deprecated/useless `Date` class. Instead point them in the direction of the `java.time` package. – achAmháin Dec 04 '18 at 20:54