LocalTime format(DateTimeFormatter formatter) example
Description
LocalTime format(DateTimeFormatter formatter)
formats this time
using the specified formatter.
Syntax
format
has the following syntax.
public String format(DateTimeFormatter formatter)
Example
The following example shows how to use format
.
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
//w w w . j a va2 s . c o m
public class Main {
public static void main(String[] args) {
LocalTime l = LocalTime.now();
String s = l.format(DateTimeFormatter.ISO_LOCAL_TIME);
System.out.println(s);
}
}
The code above generates the following result.