package cz.senslog.connector.tools.util;

import java.time.LocalDateTime;
import java.time.ZoneOffset;
import java.util.Date;

public final class LocalDateTimeUtils {

    public static LocalDateTime valueOf(Object object) {

        if (object == null) {
            return null;
        }

        if (object instanceof LocalDateTime) {
            return (LocalDateTime) object;
        }

        if (object instanceof Date) {
            Date date = (Date) object;
            return date.toInstant().atZone(ZoneOffset.systemDefault()).toLocalDateTime();
        }

        return null;
    }
}
