查询当前日期是星期几
public static String getWeek(String date) throws ParseException { String[] weeks = {"1","2","3","4","5","6","7"}; Calendar cal = Calendar.getInstance(); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-mm-dd"); cal.setTime(simpleDateFormat.parse(date)); int week_index = cal.get(Calendar.DAY_OF_WEEK) - 1; if(week_index<0){ week_index = 0; } return weeks[week_index]; } public static void main(String[] args) throws ParseException { System.out.println(TimingHd.getWeek("2022-05-28")); }