localdate converter
This commit is contained in:
parent
9b550e6554
commit
6202b7caab
|
@ -10,15 +10,15 @@ import java.util.Optional;
|
||||||
public class LocalDateConverter implements AttributeConverter<LocalDate, Date> {
|
public class LocalDateConverter implements AttributeConverter<LocalDate, Date> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Date convertToDatabaseColumn(LocalDate localDateTime) {
|
public Date convertToDatabaseColumn(LocalDate localDate) {
|
||||||
return Optional.ofNullable(localDateTime)
|
return Optional.ofNullable(localDate)
|
||||||
.map(Date::valueOf)
|
.map(Date::valueOf)
|
||||||
.orElse(null);
|
.orElse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LocalDate convertToEntityAttribute(Date timestamp) {
|
public LocalDate convertToEntityAttribute(Date date) {
|
||||||
return Optional.ofNullable(timestamp)
|
return Optional.ofNullable(date)
|
||||||
.map(Date::toLocalDate)
|
.map(Date::toLocalDate)
|
||||||
.orElse(null);
|
.orElse(null);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue