Search code examples
javadatesqldatetime

String date to java sql date conversion


i need to format this String date Tue Sep 23 14:36:59 PKT 2014 to java sql date but i need both date and time, i tried this

String st = "Tue Sep 23 14:36:59 PKT 2014";
new java.sql.Date(new SimpleDateFormat("EEE MMM dd hh:mm:ss zzz yyyy").parse(st).getTime())

but it returns only date part and time part is 00:00 can any one help me to sort this issue out.

Regards and thanks in advance.


Solution

  • java.sql.Date doesn't contain time information. You should look at java.sql.Timestamp instead