/**
* 根据日期格式2015-11-03 转化成星期几
*/
String date = "2015-11-03";
public static String getWeek(String date) {
String Week = "";
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
Calendar c = Calendar.getInstance();
try {
c.setTime(format.parse(pTime));
} catch(ParseException e) {
e.printStackTrace();
}
if (c.get(Calendar.DAY_OF_WEEK) == 1) {
Week += "星期天";
}
if (c.get(Calendar.DAY_OF_WEEK) == 2) {
Week += "星期一";
}
if (c.get(Calendar.DAY_OF_WEEK) == 3) {
Week += "星期二";
}
if (c.get(Calendar.DAY_OF_WEEK) == 4) {
Week += "星期三";
}
if (c.get(Calendar.DAY_OF_WEEK) == 5) {
Week += "星期四";
}
if (c.get(Calendar.DAY_OF_WEEK) == 6) {
Week += "星期五";
}
if (c.get(Calendar.DAY_OF_WEEK) == 7) {
Week += "星期六";
}
return Week;
}
根据年月日获取星期的方法
最新推荐文章于 2021-12-15 11:19:53 发布