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

org.tkit.quarkus.rs.mappers.OffsetDateTimeMapper Maven / Gradle / Ivy

The newest version!
package org.tkit.quarkus.rs.mappers;

import java.time.LocalDateTime;
import java.time.OffsetDateTime;
import java.time.ZoneOffset;

import jakarta.enterprise.context.ApplicationScoped;

@ApplicationScoped
public class OffsetDateTimeMapper {

    public OffsetDateTime map(LocalDateTime dateTime) {
        if (dateTime == null) {
            return null;
        }
        return OffsetDateTime.of(dateTime, ZoneOffset.systemDefault().getRules().getOffset(dateTime));
    }

    public LocalDateTime map(OffsetDateTime offsetDateTime) {
        if (offsetDateTime == null) {
            return null;
        }
        return LocalDateTime.ofInstant(offsetDateTime.toInstant(), ZoneOffset.systemDefault());
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy