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