Here you can find the source of getMonthBegin(Calendar calendar)
public static Date getMonthBegin(Calendar calendar)
//package com.java2s; import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; public class Main { public static Date getMonthBegin(Calendar calendar) { if (calendar == null) { return null; }// ww w .ja v a 2 s . com Calendar date = new GregorianCalendar(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DAY_OF_MONTH)); int dm = date.get(Calendar.DAY_OF_MONTH); while (dm != 1) { date.add(Calendar.DATE, -1); dm = date.get(Calendar.DAY_OF_MONTH); } return date.getTime(); } }