改变日期选择范围

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()) 先转换格式 按中国标准。

4. 最终在 jsp 页面使用一下方法选择日期

<input type="text" class="regist-input"
	onclick="WdatePicker({isShowOK:false,isShowToday:false,isShowClear:false,readOnly:true,dateFmt:'yyyy-MM-dd HH:mm:ss',maxDate:'${student.studentDate}'});" >

  * maxDate 是限制选择日期最大值不超过哪个值。还可以选择 minDate  最小值选择不超过哪个值.

5. 效果如下:

6. 需要引入的 js 文件

<script type="text/javascript" src="${ctx}/My97DatePicker/WdatePicker.js"></script>

 

7. WdatePicker.js 插件提取地址

链接:https://pan.baidu.com/s/1guf2lEZoYVD0PMGU5ahHzg
提取码:nrfh

如果链接失败请在下方留言

 

posted on 2018-09-11 16:25  蒙古码农  阅读(496)  评论(0编辑  收藏  举报