Java tutorial
//package com.java2s; import java.util.Calendar; import java.util.Date; public class Main { public static Date firstDayOfMonth(Date date) { Calendar cal = Calendar.getInstance(); cal.setTime(date); cal.set(Calendar.DAY_OF_MONTH, Calendar.getInstance().getActualMinimum(Calendar.DAY_OF_MONTH)); cal.set(Calendar.HOUR_OF_DAY, Calendar.getInstance().getActualMinimum(Calendar.HOUR_OF_DAY)); cal.set(Calendar.MINUTE, Calendar.getInstance().getActualMinimum(Calendar.MINUTE)); return cal.getTime(); } }