11package alexp .blog .model ;
22
33import alexp .blog .service .MarkdownConverter ;
4+ import alexp .blog .utils .LocalDateTimePersistenceConverter ;
45import org .hibernate .validator .constraints .NotBlank ;
56import org .hibernate .validator .constraints .NotEmpty ;
67import org .springframework .util .StringUtils ;
78
89import javax .persistence .*;
910import javax .validation .constraints .Size ;
11+ import java .time .LocalDateTime ;
1012import java .util .ArrayList ;
1113import java .util .Collection ;
1214import java .util .Date ;
@@ -30,9 +32,9 @@ public class Post {
3032 @ Column (nullable = false )
3133 private String fullPostText ;
3234
33- @ Column (columnDefinition = "DATETIME" , nullable = false )
34- @ Temporal ( TemporalType . TIMESTAMP )
35- private Date dateTime ;
35+ @ Column (nullable = false )
36+ @ Convert ( converter = LocalDateTimePersistenceConverter . class )
37+ private LocalDateTime dateTime ;
3638
3739 @ Column (nullable = false )
3840 private boolean hidden = false ;
@@ -104,11 +106,11 @@ public void setTags(Collection<Tag> tags) {
104106 this .tags = tags ;
105107 }
106108
107- public Date getDateTime () {
109+ public LocalDateTime getDateTime () {
108110 return dateTime ;
109111 }
110112
111- public void setDateTime (Date dateTime ) {
113+ public void setDateTime (LocalDateTime dateTime ) {
112114 this .dateTime = dateTime ;
113115 }
114116
0 commit comments