Here you can find the source of dayForWeek(String pTime)
public static int dayForWeek(String pTime)
//package com.java2s; //License from project: Apache License import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; public class Main { public static int dayForWeek(String pTime) { SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); Calendar c = Calendar.getInstance(); try {/*from ww w . jav a 2 s. com*/ c.setTime(format.parse(pTime)); } catch (ParseException e) { e.printStackTrace(); } int dayForWeek = 0; if (c.get(Calendar.DAY_OF_WEEK) == 1) { dayForWeek = 7; } else { dayForWeek = c.get(Calendar.DAY_OF_WEEK) - 1; } return dayForWeek; } public static int dayForWeek(Date pTime) { Calendar c = Calendar.getInstance(); c.setTime(pTime); int dayForWeek = 0; if (c.get(Calendar.DAY_OF_WEEK) == 1) { dayForWeek = 7; } else { dayForWeek = c.get(Calendar.DAY_OF_WEEK) - 1; } return dayForWeek; } }