com.breuninger.boot.mongo.jobs.DateTimeConverters Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of spring-boot-starter-breuninger-mongo Show documentation
Show all versions of spring-boot-starter-breuninger-mongo Show documentation
spring-boot-starter-breuninger-mongo
package com.breuninger.boot.mongo.jobs;
import static java.time.OffsetDateTime.ofInstant;
import static java.time.ZoneId.systemDefault;
import static java.util.Date.from;
import java.time.OffsetDateTime;
import java.util.Date;
import lombok.experimental.UtilityClass;
@UtilityClass
class DateTimeConverters {
static Date toDate(final OffsetDateTime offsetDateTime) {
return from(offsetDateTime.toInstant());
}
static OffsetDateTime toOffsetDateTime(final Date date) {
return date == null ? null : ofInstant(date.toInstant(), systemDefault());
}
}