我正在尝试制作一种方法,您可以在其中输入当前月份的参数以及要追溯的月份数,并将所有这些转换为天数。例如,如果当前月份是 1 月,并且我想将过去 5 个月转换为天数,则答案将是 153。我有以下信息可供使用。
private Calendar cal;
private int currentMonth;
private final int JANUARY = 31;
private final int FEBRUARY = 28;
private final int MARCH = 31;
private final int APRIL = 30;
private final int MAY = 31;
private final int JUNE = 30;
private final int JULY = 31;
private final int AUGUST = 31;
private final int SEPTEMBER = 30;
private final int OCTOBER = 31;
private final int NOVEMBER = 30;
private final int DECEMBER = 31;
public Constructor(){
cal = new GregorianCalendar();
currentMonth = cal.get(Calendar.MONTH);
}
private int convertMonthsToDays(int currentMonth, int months){
int days;
return days;
}