Possible Duplicate:
Conversion of Date
How to convert date from m/d/yy to mm/dd/yyyy?
I get the date in a String as: 5/1/12. I need to convert it to 05/01/2012. Please suggest.
I used the following code:
SimpleDateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy");
d_date = dateFormat.parse("5/1/12");
strDate = dateFormat.format(d_date);
Result:
05/01/0012
Expected Result: 05/01/2012
Thanks Prasad