Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package de.otto.edison.jobs.repository.mongo;
 
 import java.util.Date;
 
 import static java.time.OffsetDateTime.*;
 import static java.time.ZoneId.*;
 import static java.util.Date.*;

Utility class used to convert java.time.* to and from mongoDB documents.

Author(s):
Guido Steinacker
Since:
20.07.15
public class DateTimeConverters {
    private DateTimeConverters() {}
    public static Date toDate(final OffsetDateTime offsetDateTime) {
        return from(offsetDateTime.toInstant());
    }
    public static OffsetDateTime toOffsetDateTime(final Date date) {
        return date == null ? null : ofInstant(date.toInstant(), systemDefault());
    }
New to GrepCode? Check out our FAQ X