In my project I need to select date and time when a product was created and to save it in a database. I'm making a desktop application using JavaFX and I have MySQL DB (project requirements, can't change).
My initial idea was to use javafx.scene.control.DatePicker
for date & time input, and java.sql.Timestamp
in the backend, but I'm unable to find a way to convert DatePicker
value to Timestamp
format. I need to preserve year, month, day, hours, minutes and seconds.
Is there any way to do this? If not, what other data types do you suggest?
Thanks.