SimpleDateFormat sdf = new SimpleDateFormat("YYYY-MM-dd");
Calendar c = Calendar.getInstance();
c.add(Calendar.MONTH, -2);
Date result = c.getTime();
System.out.println(result);
System.out.println(sdf.format(result));
The above snap shot was working code of my project module.But today i noticed that i am getting wrong out put as ,
Tue Dec 29 15:49:32 IST 2015
2016-12-29
my expected result is
Tue Dec 29 15:49:32 IST 2015
2015-12-29
I noticed the code is working up to feb 26 2016 (tested by changing system date.)
what is the issue here ,Thanks in sdvance