Here you can find the source of getWeekId(String date)
public static Integer getWeekId(String date)
//package com.java2s; //License from project: Open Source License import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.*; public class Main { private final static SimpleDateFormat yyyyMMdd = new SimpleDateFormat("yyyyMMdd"); public static Integer getWeekId(String date) { Date d = new Date(); try {/*from w ww . jav a 2 s . c o m*/ d = yyyyMMdd.parse(date); } catch (ParseException e) { } Calendar calendar = Calendar.getInstance(); calendar.setTime(d); Integer i = calendar.get(Calendar.DAY_OF_WEEK) - 1; return i; } }