【发布时间】:2016-05-13 22:24:47
【问题描述】:
我遇到了与here 提到的相同的问题,但是当我厌倦了解决方案中的内容时,我仍然遇到相同的错误:
属性 startDate 必须是有效的 Date 属性 endDate 必须是 有效日期
这是我的域名:
class EmpRef {
String workName
String title
Date startDate
Date endDate
String reasonForLeaving
String directMgrName
String directMgrTitle
String directMgrTelephone
}
这是我的保存操作:
def save(EmpRef empRefInstance) {
empRefInstance.startDate=Date.parse('dd-MM-yyyy',params.startDate)
empRefInstance.endDate=Date.parse('dd-MM-yyyy',params.endDate)
if (empRefInstance == null) {
notFound()
return
}
if (empRefInstance.hasErrors()) {
respond empRefInstance.errors, view:'create'
return
}
empRefInstance.save flush:true
}
GSP 中的 jQuery 代码:
$('.datePicker').datepicker({
changeYear: true,
changeMonth: true,
autoSize: true,
dateFormat: "dd-mm-yy",
maxDate: "0y",
showAnim: "show",
yearRange:'c-70:c+0'
});
【问题讨论】:
-
dd-MM vs dd-mm 试图看看有什么区别?月与分钟
标签: validation grails