Stepping on the pit series "five" Incorrect datetime value: the reason for the failure of adding time

When adding the time through the new Date() method in the unit test, it reported Data truncation: Incorrect datetime value: such an error (the time type of my database table is datetime). In
Insert picture description here
this case, see if your SQL statement is successful Corresponding to

Insert picture description here
Like me, the order is wrong, because the data fails to be added because of the type, and it can be successfully added after adjustment. Another situation is that you may need to set the time format SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); l Similar to this, there are many methods anyway, just add it.

Guess you like

Origin blog.csdn.net/hyx1249273846/article/details/106336921