Here you can find the source of getTodayDiff(String diffDate)
public static final int getTodayDiff(String diffDate)
//package com.java2s; //License from project: Apache License import java.util.Calendar; import java.util.Date; public class Main { public static final int getTodayDiff(String diffDate) { int diffCnt = 0; int yyyy = 0; int mm = 0; int dd = 0; Date today = new Date(); yyyy = Integer.parseInt(diffDate.substring(0, 4)); mm = Integer.parseInt(diffDate.substring(4, 6)); dd = Integer.parseInt(diffDate.substring(6, 8)); Calendar cal = Calendar.getInstance(); Calendar cal2 = Calendar.getInstance(); cal.setTime(today);/* w w w .ja v a 2s . co m*/ cal.add(Calendar.MONTH, 1); cal2.set(yyyy, mm, dd); if (cal2.before(cal)) { while (!cal2.after(cal)) { ++diffCnt; cal2.add(Calendar.DATE, 1); } } else { while (!cal2.before(cal)) { --diffCnt; cal2.add(Calendar.DATE, -1); } } return diffCnt; } }