Here you can find the source of getWeekOfMonth(String year, String month, String day)
public static int getWeekOfMonth(String year, String month, String day)
//package com.java2s; //License from project: Apache License import java.text.SimpleDateFormat; import java.util.Calendar; public class Main { public static int getWeekOfMonth(String year, String month, String day) { java.sql.Date myDate = getDate(year, month, day); int index = 0; try {/*from w ww . j av a 2 s . c om*/ Calendar cal = Calendar.getInstance(); cal.setTime(myDate); index = cal.get(Calendar.DAY_OF_WEEK); if (index <= 1) { index = 7; } else { index = index - 1; } } catch (Exception e) { e.printStackTrace(); } return index; } public static java.sql.Date getDate(String year, String month, String day) { java.sql.Date result = null; try { String str = year + "-" + month + "-" + day; SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); java.util.Date date1 = dateFormat.parse(str); result = new java.sql.Date(date1.getTime()); } catch (Exception e) { System.out.println("Exception " + e); } return result; } }