java - DateFormat giving incorrect value -
i wanted convert string date. code:
string maturitydate = "20150722"; simpledateformat formatter = new simpledateformat("yyyymmdd"); date date = formatter.parse(maturitydate); system.out.println(date); expected result :
input 20150722 output wed jul 22 00:07:00 ist 2015 actual result :
input 20150722 output thu jan 22 00:07:00 ist 2015 what cause?
what cause?
cause m letter means minute in simpledateformat pattern. mean m months.
solution
change format yyyymmdd yyyymmdd.
simpledateformat formatter = new simpledateformat("yyyymmdd"); in api find complete list:
m month in year month july; jul; 07 m minute in hour number 30
Comments
Post a Comment