-2

Spring boot 2 has made UTC format the default for dates when serializing objects as json. This broke several of our old integrations that relied on the date being a timestamp. How do I selectively restore this functionality to the responses that need it?

Taugenichts
  • 1,307
  • 12
  • 19
  • can I get context for the minus votes? This caused a bug when we upgraded a system to springboot 2 so it is a serious problem. – Taugenichts Feb 28 '20 at 20:58

1 Answers1

1

On any dates you need formatted as a timestamp again, in either the constructor or on the field annotate them with @JsonFormat(shape = JsonFormat.Shape.NUMBER) like so:

@JsonFormat(shape = JsonFormat.Shape.Number)
private Date myDate;

or

MyClass(@JsonFormat(shape = JsonFormat.Shape.Number)
        Date myDate) {
...
}
Taugenichts
  • 1,307
  • 12
  • 19