如何設置上個月的最短日期26.這是我的代碼。如何設置上個月的最短日期26
int difference = 0;
if (month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12) {
difference = 31;
} else if (month == 4 || month == 6 || month == 9 || month == 11) {
difference = 30;
} else if (month == 2) {
if (year % 4 == 0) {
difference = 29;
} else
difference = 28;
}
int minDiffrence = 0;
if (day == 26) {
minDiffrence = difference;
} else {
minDiffrence = difference - (26 - day);
}
dpd.getDatePicker().setMinDate(System.currentTimeMillis() - 24 * 60 * 60 * 1000 * minDiffrence);
在頂部,你說你想要上個月的第26個月,但你的代碼示例似乎是在這個月的最後一天。請澄清。你的問題不清楚。 –