Here you can find the source of getFirstDayOfMonth(Date date)
public static Date getFirstDayOfMonth(Date date)
//package com.java2s; //License from project: Apache License import java.util.Calendar; import java.util.Date; public class Main { public static Date getFirstDayOfMonth(int year, int month) { Calendar calender = Calendar.getInstance(); calender.set(year, month - 1, 1); calender.set(Calendar.DAY_OF_MONTH, calender.getActualMinimum(Calendar.DAY_OF_MONTH)); setStartTimeOfDay(calender);//from w w w.j av a 2 s.co m return calender.getTime(); } public static Date getFirstDayOfMonth(Date date) { Calendar calender = Calendar.getInstance(); calender.setTime(date); calender.set(Calendar.DAY_OF_MONTH, calender.getActualMinimum(Calendar.DAY_OF_MONTH)); setStartTimeOfDay(calender); return calender.getTime(); } private static void setStartTimeOfDay(Calendar calender) { calender.set(Calendar.HOUR_OF_DAY, calender.getActualMinimum(Calendar.HOUR_OF_DAY)); calender.set(Calendar.MINUTE, calender.getActualMinimum(Calendar.MINUTE)); calender.set(Calendar.SECOND, calender.getActualMinimum(Calendar.SECOND)); calender.set(Calendar.MILLISECOND, calender.getActualMinimum(Calendar.MILLISECOND)); } }