Java SimpleDateFormat with pattern "MM/DD/yyyy" produces unexpected date value -


i trying create date object input string. code snippet have written :

inputs : effdate = "03/09/2012" , expirydate = "08/31/2012"  system.out.println("eff date: " + effdate);  simpledateformat formatter = new simpledateformat("mm/dd/yyyy"); date date = formatter.parse(effdate); system.out.println("effective date = " + formatter.format(date)); 

the output :

eff date: 03/09/2012 effective date = 01/09/2012 

the same happens other input well.

exp date: 08/31/2012 expiry date = 01/31/2012 

does know reason why changing month value anything(03/08) 01 ?? info: using jdk1.6 eclipse. , running sample program through junit 4.

new simpledateformat("mm/dd/yyyy"); should new simpledateformat("mm/dd/yyyy"); (dd instead of dd)

  • dd = day in year
  • dd = day in month

Comments

Popular posts from this blog

delphi - How to convert bitmaps to video? -

jasper reports - Fixed header in Excel using JasperReports -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -