java - String to Date conversion returning wrong value -


i trying convert string date... return value 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 actual output is:

fri jan 25 00:00:00 cst 2013

how month becomes jan july?

change dd dd;

dateformat formatter = new simpledateformat("yyyy-mm-dd");  

Comments

Popular posts from this blog

How to logout from a login page in asp.net -

Stack level too deep error after upgrade to rails 3.2 and ruby 1.9.3 -