Returns the LocalTime instance for the provided text and formatter. The provided text must be valid per DateTimeFormatter instance.
package com.logicbig.example.localtime;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
public class ParseExample {
public static void main (String... args) {
LocalTime t = LocalTime.parse("21:22");
System.out.println(t);
t = LocalTime.parse("20:40", DateTimeFormatter.ISO_TIME);
System.out.printf("ISO_TIME: %s%n",t);
t = LocalTime.parse("02:30",
DateTimeFormatter.ISO_LOCAL_TIME);
System.out.printf("ISO_LOCAL_TIME: %s%n",t);
}
}
Output
21:22
ISO_TIME: 20:40
ISO_LOCAL_TIME: 02:30