0

The back-end entity class uses @ jsonformat annotation, but there seems to be a problem with the time format in 24-hour and 12 hour when the front-end gets data. For example, the back-end time is 2021-5-21 00:50, but the time sent to the front-end becomes 2021-5-21 12:50. Is there a problem with the property setting of @ jsonformat or the front end.

@JsonFormat(pattern="yyyy-MM-dd hh:mm",timezone="GMT+8")
KQ 123
  • 1
  • 2
    Refer to: [Java string to date conversion](https://stackoverflow.com/questions/4216745/java-string-to-date-conversion/). `hh` - (1-12), `HH` - (0-24). – Janez Kuhar May 21 '21 at 08:42

1 Answers1

0

As suggested in comment, you just need to change the lower capital format hh (which converts hours in 12h format "1-12") to the upper capital HH (which converts hours in 24h format "0-24"), so your entire date time format should appear like this:

@JsonFormat(pattern="yyyy-MM-dd HH:mm",timezone="GMT+8")

I personally use a the @JsonSerializer and @JsonDeserializer annotations to realize more efficient conversion patterns, but I think in your case is not necessary.

Marco Tizzano
  • 1,726
  • 1
  • 11
  • 18