LocalTime truncatedTo(TemporalUnit unit) example
Description
LocalTime truncatedTo(TemporalUnit unit)
returns a copy
of this LocalTime with the time truncated.
Syntax
truncatedTo
has the following syntax.
public LocalTime truncatedTo(TemporalUnit unit)
Example
The following example shows how to use truncatedTo
.
import java.time.LocalTime;
import java.time.temporal.ChronoUnit;
/*from www . j ava 2s. co 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.