//判断星期几
public static String dayForWeek(String pTime) throws Exception {
String formatPTime = pTime.substring(0, 4)+"-"+pTime.substring(4, 6)+"-"+pTime.substring(6, 8);
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
Calendar c = Calendar.getInstance();
c.setTime(format.parse(formatPTime));
int dayForWeek = 0;
if(c.get(Calendar.DAY_OF_WEEK) == 1){
dayForWeek = 7;
}else{
dayForWeek = c.get(Calendar.DAY_OF_WEEK) - 1;
}
return String.valueOf(dayForWeek);
}
判断星期
最新推荐文章于 2025-08-15 23:10:13 发布