Skip to content
Advertisement

How to use JPA to save datetime of SQL to fix: “Conversion failed when converting date and/or time from character string.”

I got a very frustrated problem.. I cannot use the JPA save function to store correct datetime object of SQL, I got the following error:

There is my code:

In Controller:

In Entity:

Many thanks!!

Advertisement

Answer

I recomend you to use LocalDateTime of modern java.time. JPA automatically convert LocalDateTime into database datetime. To get current datetime use LocalDateTime.now().

You can take as @RequestParam also

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement