Here you can find the source of getCompareDateNum(String sDateValue1, String sDateValue2)
public static long getCompareDateNum(String sDateValue1, String sDateValue2) throws ParseException
//package com.java2s; //License from project: Apache License import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class Main { /**/*w ww .j av a 2 s . co m*/ * yyyy-MM-dd */ public static final String DATE_FORMAT = "yyyy-MM-dd"; public static long getCompareDateNum(String sDateValue1, String sDateValue2) throws ParseException { long DAY = 24L * 60L * 60L * 1000L; SimpleDateFormat df = new SimpleDateFormat(DATE_FORMAT); Date d1 = df.parse(sDateValue1); Date d2 = df.parse(sDateValue2); return ((d2.getTime() - d1.getTime()) / DAY); } }