LocalTime truncatedTo(TemporalUnit unit)
returns a copy
of this LocalTime with the time truncated.
truncatedTo
has the following syntax.
public LocalTime truncatedTo(TemporalUnit unit)
The following example shows how to use truncatedTo
.
import java.time.LocalTime; import java.time.temporal.ChronoUnit; // w w w .jav a 2 s . c o m public class Main { public static void main(String[] args) { LocalTime l = LocalTime.now(); LocalTime s = l.truncatedTo(ChronoUnit.HOURS); System.out.println(s); } }
The code above generates the following result.