Wed Oct 22, 2008 1:17 am
In my application I am getting one String variable which holds date in
yyyy-mm-dd hh:mm:ss format. It is a String type and i would like to
convert it in sql.Date. TO convert in sql.Date type i am doing the
following:
1) I am getting value in format of yyyy-mm-dd hh:mm:ss, example
2008-03-19 19:44:58
2) i am trying like:
// stringDate is holding value 2008-03-19 19:44:58
DateFormat formater = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
java.util.Date parsedUtilDate = formater.parse(stringDate);
java.sql.Date sqltDate= new java.sql.Date(parsedUtilDate.getTime());
when i convert String date i get in parsedUtilDate: Wed Mar 19
19:44:58 IST 2008
and sqltDate is having value 2008-03-19
could you please help me to get date in same format in sqltDate (as it
is stringDate), 2008-03-19 19:44:58
Wed Oct 22, 2008 1:18 am
java.sql.Date.toString() only format to yyyy-mm-dd
Use java.sql.Timestamp instead.
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com
Powered by phpBB © phpBB Group.