Here you can find the source of getLastDayByMonthWeek(int year, int month, int week)
public static String getLastDayByMonthWeek(int year, int month, int week)
//package com.java2s; //License from project: Open Source License import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; public class Main { public final static String YYYY_MM_DD = "yyyy-MM-dd"; public static String getLastDayByMonthWeek(int year, int month, int week) { DateFormat df = new SimpleDateFormat("yyyy-MM-dd "); Calendar c = Calendar.getInstance(); c.set(Calendar.YEAR, year); c.set(Calendar.MONTH, month - 1); c.set(Calendar.WEEK_OF_MONTH, week); int firstDayofweek = c.getFirstDayOfWeek(); int lastDayofweek = firstDayofweek + 6; Calendar c2 = Calendar.getInstance(); c2.set(Calendar.YEAR, year); c2.set(Calendar.MONTH, month - 1); c2.set(Calendar.WEEK_OF_MONTH, week); c2.set(Calendar.DAY_OF_WEEK, lastDayofweek); Date d2 = new Date(c2.getTimeInMillis()); return df.format(d2); }//from www . ja v a2 s . c om public static String format(Date date, String pattern) { if (date == null) return ""; else return getFormatter(pattern).format(date); } public static String format(Date date) { if (date == null) return ""; else return getFormatter(YYYY_MM_DD).format(date); } private static SimpleDateFormat getFormatter(String parttern) { return new SimpleDateFormat(parttern); } }