我制作了一个自定义日历。它将设备的日期显示为当前日期。但我的要求是将日期前 12 天显示为当前日期。例如,今天是 21,但我希望我的日历显示 9。我也想对年份做同样的事情。我知道如何获取当前日期。我正在使用此代码。
_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 = 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();