I am fetching the Year of the Current device time with this code:
Calendar cal = Calendar.getInstance();
cal.setTimeInMillis(System.currentTimeMillis());
cal.getTime().getYear();
But with that i am getting 111 instead of the 2011 as current year.
If i have set the 2012 as current year then it gives me 112 instead of the 2012.
Why it is like that ?
Please help me for that.
Thanks.
The getYear() returns the year since 1900. So you have to use
EDIT
The
Date.getYear()is deprecated. So you can usecal.get(Calendar.YEAR)to get the year field. See Date.getYear() and Calendar.get()