How to convert string date to Timestamp in java?

Posted by lakshmi on Stack Overflow See other posts from Stack Overflow or by lakshmi
Published on 2010-04-30T05:03:41Z Indexed on 2010/04/30 5:07 UTC
Read the original article Hit count: 279

Filed under:

Hi,

I want to convert string Date into Timestamp in java. The following coding i have written.I have declare the date for date1 is: 7-11-11 12:13:14.

SimpleDateFormat datetimeFormatter1 = new SimpleDateFormat(
                "yyyy-MM-dd hh:mm:ss");
Date lFromDate1 = datetimeFormatter1.parse(date1);
System.out.println("gpsdate :" + lFromDate1);
Timestamp fromTS1 = new Timestamp(lFromDate1.getTime());

I want to convert 7-11-11 12:13:14 this string date into timestamp. Now i got the output is 0007-11-11 00:13:14.000000 +05:30:00 but i want ( 7-11-11 12:13:14) this format Timestamp date. Can anyone please help me. Thank you.

© Stack Overflow or respective owner

Related posts about java