You have to get the day, month or year from a Calendar instance:
//int mesActual = new Date().getMonth() +1;//enero=0 diciembre=11
Calendar calendar = Calendar.getInstance();
int diaActual = calendar.get(Calendar.DAY_OF_WEEK);
int mesActual = calendar.get(Calendar.MONTH) + 1;
int anioActual = calendar.get(Calendar.YEAR);
It is important to note that to obtain the month you must add 1, since the first month is 0, for this reason it is obtained in this way:
int mesActual = calendar.get(Calendar.MONTH) + 1;
MONTH : Field number for get and set indicating the month. This is a calendar-specific value. The first month of the year in the Gregorian and Julian calendars is JANUARY which is 0; The latter depends on the number of months in a year.
@Rene Limon's answer is the solution, you could omit the date to write less unnecessary lines of code, leaving it like this:
Thus:
You have to get the day, month or year from a Calendar instance:
It is important to note that to obtain the month you must add 1, since the first month is 0, for this reason it is obtained in this way: