localdate converter

This commit is contained in:
mherbaghinyan 2019-01-10 15:18:21 +04:00
parent 9b550e6554
commit 6202b7caab
1 changed files with 4 additions and 4 deletions

View File

@ -10,15 +10,15 @@ import java.util.Optional;
public class LocalDateConverter implements AttributeConverter<LocalDate, Date> {
@Override
public Date convertToDatabaseColumn(LocalDate localDateTime) {
return Optional.ofNullable(localDateTime)
public Date convertToDatabaseColumn(LocalDate localDate) {
return Optional.ofNullable(localDate)
.map(Date::valueOf)
.orElse(null);
}
@Override
public LocalDate convertToEntityAttribute(Date timestamp) {
return Optional.ofNullable(timestamp)
public LocalDate convertToEntityAttribute(Date date) {
return Optional.ofNullable(date)
.map(Date::toLocalDate)
.orElse(null);
}