Here you can find the source of dateDiff(Timestamp t1, Timestamp t2, int type)
public static float dateDiff(Timestamp t1, Timestamp t2, int type)
//package com.java2s; //License from project: Open Source License import java.sql.Timestamp; public class Main { public static float dateDiff(Timestamp t1, Timestamp t2, int type) { float i = t1.getTime() - t2.getTime(); float f = 0.0f;// i / (1000 * 60); switch (type) { case 1:// hour f = i / (1000 * 60 * 60);//from ww w . j a v a 2 s. c o m break; case 2:// min f = i / (1000 * 60); break; case 3:// sec f = i / (1000); break; case 0: // defaut is day f = i / (1000 * 60 * 60 * 24); } String temp = "#,##0.0"; try { return Float.valueOf(new java.text.DecimalFormat(temp).format(f)); } catch (Exception e) { ;// System.out.println(e); } return f; } }