Java examples for java.sql:Timestamp
get Day Start as java.sql.Timestamp
//package com.java2s; import java.util.Calendar; public class Main { public static java.sql.Timestamp getDayStart(java.sql.Timestamp stamp) { return getDayStart(stamp, 0); }//from ww w . ja va2s . c o m public static java.sql.Timestamp getDayStart(java.sql.Timestamp stamp, int daysLater) { Calendar tempCal = Calendar.getInstance(); tempCal.setTime(new java.util.Date(stamp.getTime())); tempCal.set(tempCal.get(Calendar.YEAR), tempCal.get(Calendar.MONTH), tempCal.get(Calendar.DAY_OF_MONTH), 0, 0, 0); tempCal.add(Calendar.DAY_OF_MONTH, daysLater); return new java.sql.Timestamp(tempCal.getTime().getTime()); } }