Here you can find the source of getMonthFirstDate(final Date date, final String format)
public static String getMonthFirstDate(final Date date, final String format)
//package com.java2s; //License from project: Apache License import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; public class Main { public static Date getMonthFirstDate(final Date date) { Calendar calendar = Calendar.getInstance(); calendar.setTime(date);/* ww w . j av a2 s. co m*/ calendar.set(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), 1, 0, 0, 0); return calendar.getTime(); } public static String getMonthFirstDate(final Date date, final String format) { Date monthFirstDate = getMonthFirstDate(date); SimpleDateFormat dateFormat = new SimpleDateFormat(format); return dateFormat.format(monthFirstDate); } }