Please advise how can I convert the date that I am getting in String form
to java.sql.Date form..
String Dateimp = abcObject.getabcDate();
java.sql.Date sd = ????? // what should i write in here.
at last finally i want to convert the date that I am getting in String form to java.sql.Date
You need to know the exact format of your string, for intance if your date is formatted as "2014-01-30",
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
java.util.Date date = df.parse(Dateimp);
// if you really need java.sql.Date
java.sql.Date sqlDate = new java.sql.Date(date.getTime());
Read how to build the date pattern here http://docs.oracle.com/javase/6/docs/api/java/text/SimpleDateFormat.html
Try this
SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd");
Date parsedate = format.parse(YOUR STRING DATE);
java.sql.Date sql = new java.sql.Date(parsedate.getTime());
Last line will convert your Date object to SQL Date.
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