根据日期判断是这一周的第几天

String today = "2010-08-15";
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
Date date = format.parse(today);
Calendar calendar = Calendar.getInstance();
calendar.setFirstDayOfWeek(Calendar.MONDAY);//设置每周的第一天为周一
calendar.setTime(date);
System.out.println(calendar.get(Calendar.WEEK_OF_YEAR));
System.out.println(calendar.get(Calendar.DAY_OF_WEEK));

posted @ 2021-01-04 08:55  路要一步一步走  阅读(91)  评论(0编辑  收藏  举报