我使用Android Studio。我想從我指定的日期算起280天后的那一天。按指定的天數計算日期
Calendar thatDay = Calendar.getInstance(); //today date
thatDay.set(Calendar.DAY_OF_MONTH,selectedday);
thatDay.set(Calendar.MONTH,selectedmonth-1); // 0-11 so 1 less
thatDay.set(Calendar.YEAR, selectedyear);
Calendar afterday= Calendar.getInstance(); //280 after date
afterday.set(Calendar.DAY_OF_MONTH,selectedday+10);
afterday.set(Calendar.MONTH,selectedmonth+8);
afterday.set(Calendar.YEAR, selectedyear);
Log.e(" After Day: ", " days:" + (afterday.getTimeInMillis()- thatDay.getTimeInMillis())/ (24 * 60 * 60 * 1000));
日誌輸出變量。有時285283279種
真不簡單,謝謝:) –