Here you can find the source of getStartOfMonth(Date dt)
public static Date getStartOfMonth(Date dt)
//package com.java2s; //License from project: Open Source License import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; public class Main { /**/*from w w w . j av a 2s.c o m*/ * Return the first day of the month from the Date given Hour, minutes, * seconds are set to 0:00:00 * * @return */ public static Date getStartOfMonth(Date dt) { if (dt == null) return null; GregorianCalendar gc = new GregorianCalendar(); gc.setTime(dt); gc.set(Calendar.DAY_OF_MONTH, 1); gc.set(Calendar.HOUR_OF_DAY, 0); gc.set(Calendar.MINUTE, 0); gc.set(Calendar.SECOND, 0); gc.set(Calendar.MILLISECOND, 0); return gc.getTime(); } }