Java tutorial
//package com.java2s; //License from project: Apache License import java.util.Calendar; public class Main { /** * calculate day count * @param startYear start year * @param startMonth start month * @param startDay start day * @param endYear end year * @param endMonth end month * @param endDay end day * @return day count */ public static int countDays(int startYear, int startMonth, int startDay, int endYear, int endMonth, int endDay) { Calendar startC = Calendar.getInstance(); startC.set(Calendar.YEAR, startYear); startC.set(Calendar.MONTH, startMonth - 1); startC.set(Calendar.DAY_OF_MONTH, startDay); Calendar endC = Calendar.getInstance(); endC.set(Calendar.YEAR, endYear); endC.set(Calendar.MONTH, endMonth - 1); endC.set(Calendar.DAY_OF_MONTH, endDay); return (int) ((endC.getTimeInMillis() - startC.getTimeInMillis()) / 86400000 + 1); } }