I created a custom Calendar.It shows the device date as the current date. But my requirement is to show 12 days before the date as the current date. for example, today is 21, but I want my calendar to show 9. I want to do the same with the year. I know how to get the current date. I am using this code.
_calendar = Calendar.getInstance(Locale.getDefault());
month = _calendar.get(Calendar.MONTH) + 1;
year = _calendar.get(Calendar.YEAR);
Log.d(tag, "Calendar Instance:= " + "Month: " + month + " " + "Year: " + year);
My new code
_calendar = Calendar.getInstance(Locale.getDefault());
month = _calendar.get(Calendar.MONTH) + 1;
year = _calendar.get(Calendar.YEAR);
Log.d(tag, "Calendar Instance:= " + "Month: " + month + " " + "Year: " + year);
/*_calendar.add(Calendar.DAY_OF_YEAR, -12);*/
_calendar.roll(Calendar.DAY_OF_MONTH, -12);
_calendar.roll(Calendar.MONTH, -12);
Calendar _calendar=Calendar.getInstance();
source
share