com.jwebmp.entityassist.converters.LocalDateAttributeConverter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of entity-assist Show documentation
Show all versions of entity-assist Show documentation
A Domain Driven SQL Builder Generator for JPMS/JDK8
package com.jwebmp.entityassist.converters;
import javax.persistence.AttributeConverter;
import javax.persistence.Converter;
import java.io.Serializable;
import java.sql.Date;
import java.time.LocalDate;
@Converter()
public class LocalDateAttributeConverter implements AttributeConverter, Serializable
{
@Override
public Date convertToDatabaseColumn(LocalDate locDate)
{
return (locDate == null ? null : Date.valueOf(locDate));
}
@Override
public LocalDate convertToEntityAttribute(Date sqlDate)
{
return (sqlDate == null ? null : sqlDate.toLocalDate());
}
}