LocalTime parse(CharSequence text) example
Description
LocalTime parse(CharSequence text)
gets an instance
of LocalTime from a text string such as 10:15.
The string must represent a valid time and is parsed using DateTimeFormatter.ISO_LOCAL_TIME
.
Syntax
parse
has the following syntax.
public static LocalTime parse(CharSequence text)
Example
The following example shows how to use parse
.
import java.time.LocalTime;
//from w ww . j a v a 2 s . c o m
public class Main {
public static void main(String[] args) {
LocalTime l = LocalTime.parse("12:34");
System.out.println(l);
}
}
The code above generates the following result.