lundi 11 juillet 2016

@DateTimeFormatter without leading zero's just yyyy-MM-dd as My SQL Spring Boot

I am working with sql db in spring boot application. 1)sql type DATE and format yyyy-MM-DD.

2)when I used Temporal type, it pulls data in proper format, but while doing edit and add operations, it doesn't seem to allow.

3)when I used DateTime formatter, everything operation works fine, but data pulls up, or being added with leading zero's in application which i don't want for my application. Employee.java

    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @Column(name="birth_date")
    @NotNull @Past
//  @Temporal(TemporalType.DATE)
    private Date birthDate;



    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @Column(name="hire_date")
    @NotNull
//  @Temporal(TemporalType.DATE)
    private Date hireDate;

please advise what can be done, and to add when I change type to LocalDate, it throws

There was an unexpected error (type=Internal Server Error, status=500).
could not deserialize; nested exception is org.hibernate.type.SerializationException: could not deserialize

Aucun commentaire:

Enregistrer un commentaire