改变日期选择范围

1. SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");  // 最终显示日期格式类型

2. Calendar date = Calendar.getInstance();

3. 设置日期的范围(学生最后答题时间限制)

date.setTime(course.getCourse_end());  // 课程节课时间

date.set(Calendar.DATE, date.get(Calendar.DATE) - 3);// 课程节课时间 的前三天

student.setStudentDate(format.format(date.getTime()));  // 因为 Calendar date = Calendar.getInstance(); 是国外的日期为准,所以 format(date.getTime()) 先转换格式 按中国标准。

猜你喜欢

转载自www.cnblogs.com/bb1008/p/9628527.html