Here you can find the source of getMonthStart(Date stamp)
public static java.sql.Timestamp getMonthStart(Date stamp)
//package com.java2s; /*/* w w w .ja va2s. c o m*/ * 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 { /** * Return the date for the first day of the month */ public static java.sql.Timestamp getMonthStart(Date stamp) { return getMonthStart(stamp, 0); } public static java.sql.Timestamp getMonthStart(Date stamp, int daysLater) { Calendar tempCal = Calendar.getInstance(); tempCal.setTime(stamp); tempCal.set(tempCal.get(Calendar.YEAR), tempCal.get(Calendar.MONTH), 1, 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; } }