I have a POJO that I'm storing in JSON
format in a BLOB
column on a MySQL database table. The POJO in question has a LocalDateTime
field and whenever I persist data to the column the LocalDateTime
field takes the format described in this question, whereas I would like it to be represented in the format yyyy-MM-dd hh:mm:ss
I have tried implementing the solutions suggested in the linked post but none of them have worked. My guess is that it's something to do with the fact that the field is part of a POJO in a BLOB
as opposed to a traditional Timestamp
field.
This is the code of my POJO as it stands
public class MyPOJO {
private Long id;
@JsonFormat(pattern="yyyy-MM-dd")
@DateTimeFormat(iso = DateTimeFormat.ISO.TIME)
private LocalDateTime dateTime;
private String someText;
//Constructors
//Getters and setters
}
Any input would be welcome.
This is the current JSON output:
{
"id" : 1,
"dateTime" : {
"year" : 2010,
"month" : "JANUARY",
"dayOfMonth" : 1,
"dayOfWeek" : "FRIDAY",
"dayOfYear" : 1,
"monthValue" : 1,
"hour" : 2,
"minute" : 2,
"second" : 0,
"nano" : 0,
"chronology" : {
"id" : "ISO",
"calendarType" : "iso8601"
}
},
"someText": "someText"
}