码迷,mamicode.com
首页 > 其他好文 > 详细

根据日期返回星期几

时间:2015-07-22 20:14:27      阅读:142      评论:0      收藏:0      [点我收藏+]

标签:

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;
		}

  

根据日期返回星期几

标签:

原文地址:http://www.cnblogs.com/liuhaixu/p/4668152.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!