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; }
时间: 2024-11-06 22:19:44