Hi,Please give me the code to convert a string recieved from html page to convert it into sql date format so that i can insert in to database.

Questions by gothlururaaja

Showing Answers 1 - 1 of 1 Answers

rgoel79

  • May 25th, 2006
 

Get the date from request and use simpleDateFormat. e.g.

String str = "2006-01-01";//you can have a different pattern like MM/DD/YYYY

        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");// this should be same as format from the request
        Date dt = null;
        try {
            dt = sdf.parse(str);
        } catch (ParseException ex) {
            ex.printStackTrace();
        }
Once you have java.util.Date, you can easily convert it to sql.Date.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions