to get the current date and time
final Calendar c = Calendar.getInstance();
mYear = c.get(Calendar.YEAR);
mMonth = c.get(Calendar.MONTH);
mDay = c.get(Calend
Better to use Calendar
Calendar cal=Calendar.getInstance();
cal.set(Calendar.YEAR,myear);
(i.e)
cal.set(Calendar.YEAR,2016);
From Date.setYear(int) description: Sets the gregorian calendar year since 1900 for this Date object. Thus, 1900 + 2012 = 3912.
But calendar.get(Calendar.YEAR) returns exact year number 2012. So this inconsistency of API causes your issue. But anyway Date.setYear(int) is deprecated, thus, it is better to use Calendar object for date calculations.