Here you can find the source of daysBefore(Date date1)
public static int daysBefore(Date date1)
//package com.java2s; //License from project: Apache License import java.util.Calendar; import java.util.Date; public class Main { public static int daysBefore(Date date1) { Calendar cal = Calendar.getInstance(); cal.setTime(date1);/*from w ww .jav a 2 s . co m*/ long time1 = cal.getTimeInMillis(); long time2 = System.currentTimeMillis(); long between_days = (time2 - time1) / (1000 * 3600 * 24); return Integer.parseInt(String.valueOf(between_days)); } }