根据日期返回星期几

public static int dayForWeek(String pTime) throws Exception {
		SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
		Calendar c = Calendar.getInstance();
		c.setTime(format.parse(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;
		}

  

posted @ 2015-07-22 17:54  疯狂馒头  阅读(313)  评论(0编辑  收藏  举报