Here you can find the source of getWeekOfLastDayOfMonth(Date date)
public static int getWeekOfLastDayOfMonth(Date date)
//package com.java2s; import java.util.Calendar; import java.util.Date; public class Main { public static int getWeekOfLastDayOfMonth(Date date) { return getWeek(getLastDayOfMonth(date)); }/*from w w w. j a va2s . c om*/ public static int getWeek(Date date) { return getCalendar(date).get(7); } public static Date getLastDayOfMonth() { return getLastDayOfMonth(null); } public static Date getLastDayOfMonth(Date date) { Calendar c = getCalendar(getFirstDayOfMonth(date)); c.add(2, 1); c.add(5, -1); return getCleanDay(c); } public static Calendar getCalendar(Date day) { Calendar c = Calendar.getInstance(); if (day != null) c.setTime(day); return c; } public static Date getFirstDayOfMonth(Date date) { return getFirstCleanDay(5, date); } public static Date getFirstDayOfMonth() { return getFirstDayOfMonth(null); } private static Date add(int datePart, int detal, Date date) { Calendar c = Calendar.getInstance(); if (date != null) c.setTime(date); c.add(datePart, detal); return c.getTime(); } 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(); } 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); } }