In the http request JSON data, the releaseDate
is 10/11/2022
in String format. After spring boot converts the JSON request into java bean. the releaseDate
is converted to Mon Oct 10 18:00:00 MDT 2022
. When I save it in the sql table, the releaseDate
was changed to 10/10/2022
. How should I change the setting? Thanks.
@PutMapping("/release/statusChange/{id}")
public BasicReleaseDto updateReleaseBeanStatus(@PathVariable long id, @RequestBody ReleaseBean newReleaseBean) {
@Temporal(TemporalType.DATE)
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "MM/dd/yyyy")
@Column(name = "RELEASE_DATE")
java.util.Date releaseDate;
CodePudding user response:
use this:
@Temporal(value = TemporalType.TIMESTAMP)
private Date ;
CodePudding user response:
Use the data type below if you want to reflect the time in SQL. If you have changed the data type once created with the different data type, you have to delete the column first and then run your application, it will automatically create the new column with the desired data type. and if it will not work then when you are doing setReleaseDate first convert it into desired data type, then set
LocalDateTime releaseDate;