java实现一个月的最后一个星期天
Calendar instance = Calendar.getInstance(); System.out.println(instance.getTime()); instance.add(Calendar.MONTH, 1);//月份+1 instance.set(Calendar.DAY_OF_MONTH, 1);//天设为一个月的第一天 System.out.println(instance.getTime()); instance.add(Calendar.DAY_OF_MONTH, -1);//本月最后一天 System.out.println(instance.getTime()); instance.add(Calendar.DAY_OF_MONTH, 1 - instance.get(Calendar.DAY_OF_WEEK));//依据月末最后一天是星期几,向前偏移至近期的周日 System.out.println(instance.getTime());