Instant truncatedTo(TemporalUnit unit) example
Description
Instant truncatedTo(TemporalUnit unit)
returns a copy of this
Instant truncated to the specified unit.
Syntax
truncatedTo
has the following syntax.
public Instant truncatedTo(TemporalUnit unit)
Example
The following example shows how to use truncatedTo
.
import java.time.Instant;
import java.time.temporal.ChronoUnit;
/*ww w . j a v a2s . c o m*/
public class Main {
public static void main(String[] args) {
Instant instant = Instant.parse("2014-12-03T10:15:30.00Z");
instant = instant.truncatedTo(ChronoUnit.DAYS);
System.out.println(instant);
}
}
The code above generates the following result.