Here you can find the source of getDayStart(Date stamp)
public static java.sql.Timestamp getDayStart(Date stamp)
//package com.java2s; /*/*w ww . j a va2 s.c om*/ * DateTimeUtils.java * * Copyright (c) 1998 - 2006 BusinessTechnology, Ltd. * All rights reserved * * This program is the proprietary and confidential information * of BusinessTechnology, Ltd. and may be used and disclosed only * as authorized in a license agreement authorizing and * controlling such use and disclosure * * Millennium ERP system. * */ import java.util.Calendar; import java.util.Date; public class Main { public static java.sql.Timestamp getDayStart(Date stamp) { return getDayStart(stamp, 0); } public static java.sql.Timestamp getDayStart(Date stamp, int daysLater) { Calendar tempCal = Calendar.getInstance(); tempCal.setTime(stamp); 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); java.sql.Timestamp retStamp = new java.sql.Timestamp(tempCal.getTime().getTime()); retStamp.setNanos(0); return retStamp; } }