dd/mm/yyyy vs dd/MM/yyyy?

user3198603 picture user3198603 · Mar 23, 2014 · Viewed 59.4k times · Source
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
        String date = sdf.format(new Date()); 
        System.out.println(date); 

Result is todays date i.e 23/03/2014

But when i do

 SimpleDateFormat sdf = new SimpleDateFormat("dd/mm/yyyy"); 

result can be 23/05/2014, 23/05/2014, 23/06/2014 and son with each run of prgram. Why so?

Answer

T.J. Crowder picture T.J. Crowder · Mar 23, 2014

It's because mm is for minutes, not months. More in the documentation.