Created
April 27, 2014 01:07
-
-
Save fabriciofx/11335227 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package icob.model.entity.converter; | |
| import java.sql.Timestamp; | |
| import javax.persistence.AttributeConverter; | |
| import javax.persistence.Converter; | |
| import org.joda.time.LocalDateTime; | |
| @Converter(autoApply = true) | |
| public class LocalDateTimeConverter | |
| implements AttributeConverter<LocalDateTime, Timestamp> { | |
| public Timestamp convertToDatabaseColumn(LocalDateTime dateTime) { | |
| return new Timestamp(dateTime.toDateTime().getMillis()); | |
| } | |
| public LocalDateTime convertToEntityAttribute(Timestamp date) { | |
| return LocalDateTime.fromDateFields(date); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment