Here you can find the source of getDiffDay(Timestamp time1, Timestamp time2)
@SuppressWarnings("deprecation") public static int getDiffDay(Timestamp time1, Timestamp time2)
//package com.java2s; /*/*from w w w. j a v a2 s . c o m*/ * Copyright (c) 2014. Lorem ipsum dolor sit amet, consectetur adipiscing elit. * http://www.apache.org/licenses/LICENSE-2.0 */ import java.sql.Timestamp; import java.util.Date; public class Main { @SuppressWarnings("deprecation") public static int getDiffDay(Timestamp time1, Timestamp time2) { return getDay1(new Date(time2.getTime()), new Date(time1.getTime())); } @SuppressWarnings("deprecation") public static int getDay1(Date d1, Date d2) { if (d1 == null) return 1; d1.setHours(0); d1.setMinutes(0); d1.setSeconds(0); d2.setHours(0); d2.setMinutes(0); d2.setSeconds(0); long date1 = d1.getTime() / (1000l * 60 * 60 * 24); long date2 = d2.getTime() / (1000l * 60 * 60 * 24); return Long.valueOf(date2 - date1).intValue(); } }