码迷,mamicode.com
首页 > 其他好文 > 详细

JodaTime library not available - @DateTimeFormat not supported

时间:2014-12-26 14:19:22      阅读:597      评论:0      收藏:0      [点我收藏+]

标签:

使用spring的@DateTimeFormat来格式化Date类型时,报错:

org.springframework.validation.BindException: org.springframework.validation.BeanPropertyBindingResult: 1 errors
Field error in object ‘modelInfoExample‘ on field ‘birthday‘:
rejected value [2014-12-09];
codes [typeMismatch.modelInfoExample.birthday,typeMismatch.birthday,typeMismatch.java.util.Date,typeMismatch];
arguments [org.springframework.context.support.DefaultMessageSourceResolvable:
codes [modelInfoExample.birthday,birthday]; arguments []; default message [birthday]];
default message [Failed to convert property value of type ‘java.lang.String‘ to required type ‘java.util.Date‘
for property ‘birthday‘; 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 ‘2014-12-09‘; nested exception is
java.lang.IllegalStateException: JodaTime library not available - @DateTimeFormat not supported]

 

很明显,确实 JodaTime 库,在pom.xml中加入其依赖,搞定:

<dependency>
			<groupId>joda-time</groupId>
			<artifactId>joda-time</artifactId>
			<version>2.6</version>
		</dependency>

 

JodaTime library not available - @DateTimeFormat not supported

标签:

原文地址:http://www.cnblogs.com/digdeep/p/4186627.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!