I have a field in my database (MYSQL) with datetime type (with this format 2011-05-18 16:29:31), I dont know this type! because I Have to convert a String to this type. I have found java.sql.Date and java.sql.Timestamp and not datetime!
mysql datetime
maps to a java.sql.Timestamp
- they are both a "date plus a time"
To convert a String to a Date, use this code:
java.util.Date date = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse("2011-05-18 16:29:31");
java.sql.Timestamp timestamp = new java.sql.Timestamp(date.getTime());
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With