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

grails.gorm.time.ZonedDateTimeConverter.groovy Maven / Gradle / Ivy

There is a newer version: 8.1.2
Show newest version
package grails.gorm.time

import groovy.transform.CompileStatic

import java.time.Instant
import java.time.ZonedDateTime

/**
 * A trait to convert a {@link java.time.ZonedDateTime} to and from a long
 *
 * @author James Kleeh
 */
@CompileStatic
trait ZonedDateTimeConverter implements TemporalConverter {

    @Override
    Long convert(ZonedDateTime value) {
        value.toInstant().toEpochMilli()
    }

    @Override
    ZonedDateTime convert(Long value) {
        ZonedDateTime.ofInstant(Instant.ofEpochMilli(value), systemOffset)
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy