下面列出了java.time.OffsetDateTime#truncatedTo ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
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;
}
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;
}
/**
* 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);
}