2つの日付の間隔を取得する。 public static long dateDiff(Date d1, Date d2, int field) { Calendar c1 = Calendar.getInstance(); Calendar c2 = Calendar.getInstance(); c1.setTime(d1); c2.setTime(d2); switch (field) { case Calendar.YEAR: return diffYear(c1, c2); case Calendar.MONTH: return diffMonth(c1, c2); case Calendar.DATE: return diffDay(c1, c2); case Calendar.HOUR_OF_DAY: return diffHour(c1, c2); case Calendar