如果查看DateConverter的模型映射器源代码,它似乎仅支持java.sql.Date,java.sql.Time和java.sql.Timestamp类作为目标类型。 即使这样,在每种情况下它也仅支持源字符串的非常特定的格式。
从模型映射器DateConverter中:
Date dateFor(String source, Class> destinationType) {
String sourceString = toString().trim();
if (sourceString.length() == 0)
throw new Errors().errorMapping(source, destinationType).toMappingException();
if (destinationType.equals(java.sql.Date.class)) {
try {
return java.sql.Date.valueOf(source);
} catch (IllegalArgumentException e) {
throw new Errors().addMessage(
"String must be in JDBC format [yyyy-MM-dd] to create a java.sql.Date")
.toMappingException();
}
}
if (destinationType.equals(Time.class)) {
try {
return Time.valueOf(source);
} catch (IllegalA