Java Code Examples for java.time.OffsetDateTime#truncatedTo()

The following examples show how to use java.time.OffsetDateTime#truncatedTo() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JobInfo.java    From edison-microservice with Apache License 2.0 6 votes vote down vote up
private JobInfo(final String jobId,
                final String jobType,
                final OffsetDateTime started,
                final OffsetDateTime lastUpdated,
                final Optional<OffsetDateTime> stopped,
                final JobStatus status,
                final List<JobMessage> messages,
                Clock clock, final String hostname) {
    this.jobId = jobId;
    this.jobType = jobType;
    //Truncate to milliseconds precision because current persistence implementations only support milliseconds
    this.started = started != null ? started.truncatedTo(ChronoUnit.MILLIS) : null;
    this.lastUpdated = lastUpdated != null ? lastUpdated.truncatedTo(ChronoUnit.MILLIS) : null;
    this.stopped = stopped.map(offsetDateTime -> offsetDateTime.truncatedTo(ChronoUnit.MILLIS));
    this.status = status;
    this.messages = unmodifiableList(messages);
    this.hostname = hostname;
    this.clock = clock;
}
 
Example 2
Source File: JobMessage.java    From edison-microservice with Apache License 2.0 4 votes vote down vote up
private JobMessage(final Level level, final String message, final OffsetDateTime timestamp) {
    this.level = level;
    this.message = message;
    //Truncate to milliseconds precision because current persistence implementations only support milliseconds
    this.timestamp = timestamp != null ? timestamp.truncatedTo(ChronoUnit.MILLIS) : null;
}
 
Example 3
Source File: DateTimeExtensions.java    From groovy with Apache License 2.0 2 votes vote down vote up
/**
 * Returns an {@link java.time.OffsetDateTime} with the time portion cleared.
 *
 * @param self an OffsetDateTime
 * @return an OffsetDateTime
 * @since 2.5.0
 */
public static OffsetDateTime clearTime(final OffsetDateTime self) {
    return self.truncatedTo(DAYS);
}