public static Integer getWeekByDate(String date) {
String[] weekDays = {"星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"};
SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd");
Date tmpDate = null;
try {
tmpDate = format.parse(date);
} catch (ParseException e) {
e.printStackTrace();
}
Calendar cal = Calendar.getInstance();
cal.setTime(tmpDate);
int week = cal.get(Calendar.DAY_OF_WEEK);
if (week < 0)
week = 0;
return week-1;
}
Java中如何获取某一天是周几
最新推荐文章于 2023-03-07 10:30:55 发布