SimpleDateFormat is not a date. This class is used to format dates (transform Date for String) and make Parsing (transform String in Date) - see the documentation.
If the field in the database is a date, pass the Date - java.util.Date, or java.sql.Date (or java.sql.Timestamp, or whatever you’re using) to setParameter.
If you have a String and want to save the date, in this case you use the SimpleDateFormat to convert the String for Date:
Date date = sdf.parse(stringQueContemAData);
And then pass the Date for the method setParameter:
u.setParameter(1, date);
But as you did not specify which input and output (if it is String, Date, etc), you can’t help more than that.
Dates have no format, only values (see this article that explains this subtle difference). Just because you are seeing the date in a specific format does not necessarily mean that it is in that format.
Internally, each language, API, or database records data types in an internal format, but it doesn’t matter who uses them. When the date is displayed (printed, recorded in a file, shown on the screen, etc.), then a display format is chosen. But that doesn’t mean that the date is recorded in that format.
That being said, if the field in the bank is of the datetime type, just pass the Date for setParameter.
tried using sdf.format(date)
– Weslley Barbosa