String to Date conversion returning wrong value

date, java, string

Solution

Change the DD for dd;

DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); 

Problem

I am trying to convert a String into Date... But the return value is wrong. ``` String startDate = "2013-07-24"; Date date = new Date(); try{ DateFormat formatter = new SimpleDateFormat("yyyy-MM-DD"); date = (Date)formatter.parse(startDate); System.out.println(date); } catch(Exception e){ e.printStackTrace(); } ``` The desired output is: Thu Jul 25 00:00:00 CDT 2013 But the actual output is: Fri Jan 25 00:00:00 CST 2013 How does the month becomes Jan from July?

Original source