Here you can find the source of getFistDayOfMonth(Date date)
public static Integer getFistDayOfMonth(Date date)
//package com.java2s; //License from project: Apache License import java.util.Calendar; import java.util.Date; public class Main { public static Integer getFistDayOfMonth(Date date) { Integer intDate = getIntDate(date); int year = intDate / 10000; int month = intDate % 10000 / 100; return getIntDate(newCalendar(year, month, 1)); }//from w w w.j a v a 2 s .com public static Integer getIntDate(int year, int month, int day) { return getIntDate(newCalendar(year, month, day)); } public static Integer getIntDate(Calendar c) { int year = c.get(Calendar.YEAR); int month = c.get(Calendar.MONTH) + 1; int day = c.get(Calendar.DAY_OF_MONTH); return year * 10000 + month * 100 + day; } public static Integer getIntDate(Date d) { if (d == null) { return null; } Calendar c = Calendar.getInstance(); c.setTime(d); return getIntDate(c); } public static Calendar newCalendar(int year, int month, int day) { Calendar ret = Calendar.getInstance(); if (year < 100) { year = 2000 + year; } ret.set(year, month - 1, day); return ret; } public static Calendar newCalendar(int date) { int year = date / 10000; int month = (date % 10000) / 100; int day = date % 100; Calendar ret = Calendar.getInstance(); ret.set(year, month - 1, day); return ret; } }