Here you can find the source of getFirstDayOfMonth(Long date)
public static Long getFirstDayOfMonth(Long date)
//package com.java2s; //License from project: Apache License import java.util.*; public class Main { public static Long getFirstDayOfMonth(Long date) { Calendar cal = Calendar.getInstance(); cal.setTimeInMillis(date);/*from w w w. j a v a 2 s. c o m*/ cal.set(Calendar.HOUR_OF_DAY, 0); cal.clear(Calendar.MINUTE); cal.clear(Calendar.SECOND); cal.clear(Calendar.MILLISECOND); cal.set(Calendar.DAY_OF_MONTH, Calendar.getInstance().getActualMinimum(Calendar.DAY_OF_MONTH)); return cal.getTimeInMillis(); } public static Date getFirstDayOfMonth(Date date) { long time = getFirstDayOfMonth(date.getTime()); return new Date(time); } }