LocalTime format(DateTimeFormatter formatter)
formats this time
using the specified formatter.
format
has the following syntax.
public String format(DateTimeFormatter formatter)
The following example shows how to use format
.
import java.time.LocalTime; import java.time.format.DateTimeFormatter; //from w w w . jav a 2s . com 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.