Here you can find the source of getWeekNumByDate(String date)
public static int getWeekNumByDate(String date)
//package com.java2s; //License from project: Open Source License import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; public class Main { public static final String DF_YMD = "yyyy-MM-dd"; public static int getWeekNumByDate(String date) { SimpleDateFormat format = new SimpleDateFormat(DF_YMD); try {//from w ww . ja va 2 s . c o m Date d = format.parse(date); Calendar cal = Calendar.getInstance(); cal.setTime(d); int num = cal.get(Calendar.DAY_OF_WEEK) - 1; return num; } catch (ParseException e) { e.printStackTrace(); } return 0; } }