All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.breuninger.boot.mongo.jobs.DateTimeConverters Maven / Gradle / Ivy

There is a newer version: 2.0.5.RELEASE
Show newest version
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());
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy