-1

It`s possible to create one JsonSerialize and Deserialize with spring boot?

I put in my appliation.properties this line

spring.jackson.date-format=dd/MM/yyyy HH:mm:ss

but when I return one Date he allways returns a wrong value (yyyy-MM-dd) so I try to create one custom serialization following the http://docs.spring.io/spring-boot/docs/1.4.0.RELEASE/reference/htmlsingle/#boot-features-json-components but don`t work.

this is my return:

@Entity
@Table(name = "view_atos_praticados", catalog="db_registro", schema="db_wsprefeituraatos")
public class ViewAtosPraticados {
    @JsonIgnore
    @Id
    @Column(name="id")
    private Integer id;
    @Column(name="descricao_ato")
    private String ato;
    @JsonIgnore
    @Column(name="livro")
    private String livro;
    @JsonIgnore
    @Column(name="numero_ato")
    private Integer nrAto;
    @JsonIgnore
    @Column(name="numero_registro")
    private String nrRegistro;
    @Column(name="dat_registro")
    private Date registro;
    @Column(name="ic_transmissao")
    private String transmite;
Fabio Ebner
  • 2,613
  • 16
  • 50
  • 77

1 Answers1

-1

Try @JsonFormat annotation:

    @JsonFormat(pattern="dd/MM/yyyy HH:mm:ss")
    @Column(name="dat_registro")
    private Date registro;
Konstantin Labun
  • 3,688
  • 24
  • 24
  • Are you suggesting `spring.jackson.date-format` doesn't work for setting the `SimpleDateFormat` that Jackson uses? Why would your solution work when theirs doesn't? – Sotirios Delimanolis Aug 24 '16 at 16:57
  • @SotiriosDelimanolis if you have a problem with a small part of big system, what will be your first step? The smaller the task context the easier task. – Konstantin Labun Aug 24 '16 at 18:30
  • We're not looking to help them debug, we're looking to answer a question. If the question isn't specific enough to do that, then we ask for clarification and either wait or vote (flag if not enough reputation) to put on hold until OP edits it to clarify. Good reading material: [How do I write a good answer?](http://stackoverflow.com/help/how-to-answer) – Sotirios Delimanolis Aug 25 '16 at 01:02