Here you can find the source of getWeekOfFirstDayOfMonth(Date date)
public static int getWeekOfFirstDayOfMonth(Date date)
//package com.java2s; import java.util.Calendar; import java.util.Date; public class Main { public static int getWeekOfFirstDayOfMonth(Date date) { return getWeek(getFirstDayOfMonth(date)); }// ww w . ja v a 2 s . c om public static int getWeek(Date date) { return getCalendar(date).get(7); } public static Date getFirstDayOfMonth(Date date) { return getFirstCleanDay(5, date); } public static Date getFirstDayOfMonth() { return getFirstDayOfMonth(null); } public static Calendar getCalendar(Date day) { Calendar c = Calendar.getInstance(); if (day != null) c.setTime(day); return c; } private static Date getFirstCleanDay(int datePart, Date date) { Calendar c = Calendar.getInstance(); if (date != null) c.setTime(date); c.set(datePart, 1); return getCleanDay(c); } public static Date getCleanDay(Date day) { return getCleanDay(getCalendar(day)); } private static Date getCleanDay(Calendar c) { c.set(11, 0); c.clear(12); c.clear(13); c.clear(14); return c.getTime(); } }