如何编写一个函数来返回Gregorian Callendar中两个日期之间的天数?我应该用什么类型转换我的日期和方式?
public int substractDate(GregorianCalendar beginningDate, GregorianCalendar endingDate){
return dif;
}
答案 0 :(得分:0)
使用GregorianCalendar对象,它是Calendar的子类:
String dayPattern = "DD";
SimpleDateFormat days = new SimpleDateFormat(dayPattern);
return Integer.parseInt(days.format(endingDate.getTimeInMillis()-beginningDate.getTimeInMillis()));