Java tutorial
//package com.java2s; //License from project: LGPL import java.util.Calendar; public class Main { public static int getDateCompare(int nYear1, int nMonth1, int nDate1, int nYear2, int nMonth2, int nDate2) { Calendar cal = Calendar.getInstance(); int nTotalDate1 = 0, nTotalDate2 = 0, nDiffOfYear = 0, nDiffOfDay = 0; if (nYear1 > nYear2) { for (int i = nYear2; i < nYear1; i++) { cal.set(i, 12, 0); nDiffOfYear += cal.get(Calendar.DAY_OF_YEAR); } nTotalDate1 += nDiffOfYear; } else if (nYear1 < nYear2) { for (int i = nYear1; i < nYear2; i++) { cal.set(i, 12, 0); nDiffOfYear += cal.get(Calendar.DAY_OF_YEAR); } nTotalDate2 += nDiffOfYear; } cal.set(nYear1, nMonth1 - 1, nDate1); nDiffOfDay = cal.get(Calendar.DAY_OF_YEAR); nTotalDate1 += nDiffOfDay; cal.set(nYear2, nMonth2 - 1, nDate2); nDiffOfDay = cal.get(Calendar.DAY_OF_YEAR); nTotalDate2 += nDiffOfDay; return (nTotalDate1 - nTotalDate2) + 1; } }