在无效的Hibernate数据验证中格式化消息

在无效的Hibernate数据验证中格式化消息,hibernate,message,validation,Hibernate,Message,Validation,我想知道是否可以在Hibernate Validator中使用我的个人错误消息格式化日期格式错误 我的class属性如下所示 @DateTimeFormat(pattern = "hh:mm") private Date hourOpen; 默认错误和消息的形式为:Error spring标记 Failed to convert property value of type java.lang.String to required type java.util.Date for propert

我想知道是否可以在Hibernate Validator中使用我的个人错误消息格式化日期格式错误

我的class属性如下所示

@DateTimeFormat(pattern = "hh:mm")
private Date hourOpen;
默认错误和消息的形式为:Error spring标记

Failed to convert property value of type java.lang.String to required type java.util.Date for property hourOpen; nested exception is org.springframework.core.convert.ConversionFailedException: Failed to convert from type java.lang.String to type @org.springframework.format.annotation.DateTimeFormat java.util.Date for value 11; nested exception is java.lang.IllegalArgumentException: Unable to parse 11
我想以以下形式显示“日期格式错误”消息:errorspring标记

Failed to convert property value of type java.lang.String to required type java.util.Date for property hourOpen; nested exception is org.springframework.core.convert.ConversionFailedException: Failed to convert from type java.lang.String to type @org.springframework.format.annotation.DateTimeFormat java.util.Date for value 11; nested exception is java.lang.IllegalArgumentException: Unable to parse 11

提前谢谢。

获取默认消息的关键是:{typeMismatch.yourResultObject.objectAttribute}。

您能详细说明一下吗?您把这把钥匙放在哪里?在lang xx.properties中。@Paul在messages.properties文件中添加typemissmatch.student.dateOfBirth=出生日期:非法的日期格式!