Here you can find the source of getDifferDays(Date d1, Date d2)
public static synchronized long getDifferDays(Date d1, Date d2)
//package com.java2s; //License from project: Apache License import java.text.*; import java.util.*; public class Main { public static synchronized long getDifferDays(Date d1, Date d2) { DateFormat df1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); /*Date d1 = new Date(); Date d2 = df1.parse("2016-08-01 10:50:24");*/ long diff = d1.getTime() - d2.getTime(); long days = diff / (1000 * 60 * 60 * 24); return days; }/*from ww w .java2 s . co m*/ }