Here you can find the source of format(Timestamp time)
public static Timestamp format(Timestamp time) throws ParseException
//package com.java2s; //License from project: Open Source License import java.sql.Timestamp; import java.text.ParseException; import java.text.SimpleDateFormat; public class Main { public static Timestamp format(Timestamp time) throws ParseException { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String date = sdf.format(time); date = date.substring(0, 10) + " 00:00:00"; time = new Timestamp(sdf.parse(date).getTime()); return time; }//from ww w . j av a2s . c o m }