Java tutorial
//package com.java2s; import java.util.Calendar; import java.util.Date; public class Main { public static Date getFirstDayOfMonth(Date dateTime) { if (dateTime == null) return dateTime; Calendar calendar = Calendar.getInstance(); calendar.setTime(dateTime); calendar.set(Calendar.DAY_OF_MONTH, 1); return calendar.getTime(); } }