Java tutorial
//package com.java2s; import java.util.Calendar; import java.util.Date; public class Main { public static int getTotalWeeks(Calendar calendar) { if (null == calendar) return 0; int maxWeeks = calendar.getActualMaximum(Calendar.WEEK_OF_MONTH); return maxWeeks; } public static int getTotalWeeks(Date date) { Calendar cal = Calendar.getInstance(); cal.setTime(date); return getTotalWeeks(cal); } }