grails.gorm.time.InstantConverter.groovy Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of grails-datastore-gorm Show documentation
Show all versions of grails-datastore-gorm Show documentation
GORM - Grails Data Access Framework
package grails.gorm.time
import groovy.transform.CompileStatic
import java.time.Instant
/**
* A trait to convert a {@link java.time.Instant} to and from a long
*
* @author James Kleeh
*/
@CompileStatic
trait InstantConverter {
Long convert(Instant value) {
value.toEpochMilli()
}
Instant convert(Long value) {
Instant.ofEpochMilli(value)
}
}