public static List<String> getWeekByDate(Date date) {
List<String> dateList = new ArrayList<String>();
Calendar calendar = Calendar.getInstance();
if (date != null) {
calendar.setTime(date);
}
calendar.setFirstDayOfWeek(Calendar.MONDAY);
calendar.set(Calendar.HOUR_OF_DAY, 0);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
calendar.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
for (int i = 0; i < 7; i++) {
dateList.add(format.format(calendar.getTime()));
calendar.add(Calendar.DAY_OF_MONTH, 1);
}
return dateList;
}
Calendar获取当前日期(或自定义日期)日历的一周日期集合
最新推荐文章于 2024-04-26 19:03:27 发布