It is simple code to convert the date from string format to date format.
When the date is suppose "12/7/2009" it converts correctly
but when I have the string "12/7/09" to convert to date it coverts it to "12/7/0009"
How to get the correct converted date when the input date is "12/7/09"
But it is working correctly. As the API documentation specifically says:
For parsing, if the number of pattern letters is more than 2, the year is interpreted literally, regardless of the number of digits. So using the pattern "MM/dd/yyyy", "01/11/12" parses to Jan 11, 12 A.D.
If you mean "How do I get the year 09 to be converted to 2009" then continue reading the next paragraph of the SimpleDateFormat API documentation. (There, I provided the link for it.)