2

I am using

@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "dd-MM-yyyy hh:mm:ss", timezone = "Asia/Kolkata")
private Timestamp startDateTime;

to store timestamp comes in json as a string. But the problem is it converts time between 12 pm to 1 pm into 00 am. E.g. 2021-10-25 12:30:00 gets converted to 2021-10-25 00:30:00. Any help will be appreciated. Thank you.

FObersteiner
  • 22,500
  • 8
  • 42
  • 72
James007
  • 23
  • 3

1 Answers1

2

The root cause of the problem is that you have used h instead of H. Note that h is used for 12-hour time format (i.e. time with AM/PM marker) while H is used for 24-hour time format. So, the solution to your problem is to change the format to dd-MM-yyyy HH:mm:ss.

In case, you want the AM/PM marker in the time, change the format to dd-MM-yyyy hh:mm:ss a.

Arvind Kumar Avinash
  • 71,965
  • 6
  • 74
  • 110