Here you can find the source of getSQLDate(final Date oDate)
public static java.sql.Date getSQLDate(final Date oDate)
//package com.java2s; import java.util.Calendar; import java.util.Date; public class Main { public static final long HOUR = 60 * 60 * 1000; public static final long MINUTE = 60 * 1000; public static final long SECOND = 1000L; public static java.sql.Date getSQLDate(final Date oDate) { if (null == oDate) { return null; }// www . j av a2 s. c o m final Calendar c = Calendar.getInstance(); c.setTime(oDate); c.set(Calendar.HOUR_OF_DAY, 0); c.set(Calendar.MINUTE, 0); c.set(Calendar.SECOND, 0); c.set(Calendar.MILLISECOND, 0); return new java.sql.Date(c.getTime().getTime()); } public static String getTime(final long time) { if (time <= 0) { return ""; } if (time < SECOND) { return time + "ms"; } else if (time < MINUTE) { return (time / SECOND) + "s" + getTime(time % SECOND); } else if (time < HOUR) { return (time / MINUTE) + "m" + getTime(time % MINUTE); } else if (time >= HOUR) { return (time / HOUR) + "h" + getTime(time % HOUR); } return ""; } }