Here you can find the source of getWeek(String pTime)
public static int getWeek(String pTime) throws Exception
//package com.java2s; //License from project: Open Source License import java.text.SimpleDateFormat; import java.util.Calendar; public class Main { public static int getWeek(String pTime) throws Exception { SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); Calendar c = Calendar.getInstance(); c.setTime(format.parse(pTime));/*from w ww . java 2 s.c o m*/ int dayForWeek = 0; if (c.get(Calendar.DAY_OF_WEEK) == 1) { dayForWeek = 7; } else { dayForWeek = c.get(Calendar.DAY_OF_WEEK) - 1; } return dayForWeek; } }