Here is another simple way to solve this problem:
preparedStatement = connect.prepareStatement("INSERT INTO test.TABLENAME VALUES (default, STR_TO_DATE( ?, '%m/%d/%Y'), STR_TO_DATE(?, '%l:%i %p'),?,?,?,?,?)");
Or can you replace "?" with real data.
This is how I insert the date and time in mySQL, I just understood.
We can configure the parameters to fit our data format, itβs easy and clean.
source share