在将Long类型转换为Joda DateTime类型时,我遇到了这个异常。
org.springframework.core.convert.ConverterNotFoundException:
No converter found capable of converting from type java.lang.Long
to type org.joda.time.DateTime我正在使用
artifactId>spring-core</artifactId>
<version>4.0.3.RELEASE</version>
<artifactId>spring-integration-core</artifactId>
<version>4.0.3.RELEASE</version>
<artifactId>spring-integration-mongodb</artifactId>
<version>4.0.3.RELEASE</version>
<artifactId>spring-integration-mail</artifactId>
<version>4.0.3.RELEASE</version>
<artifactId>spring-messaging</artifactId>
<version>4.0.3.RELEASE</version>
<artifactId>spring-integration-xml</artifactId>
<version>4.0.3.RELEASE</version>
<artifactId>json-path</artifactId>
<version>0.9.1</version>
<artifactId>spring-data-commons-core</artifactId>
<version>1.4.0.RELEASE</version>
<artifactId>spring-data-commons</artifactId>
<version>1.8.1.RELEASE</version>有人知道我还需要什么才能将Long转换为DateTime吗?
谢谢
麦克
发布于 2014-07-25 22:48:50
尝试DateTime(长时间即时)路线。如果需要格式化,请尝试将长整型转换为字符串,然后使用DateTimeFormatter:
import org.joda.time.DateTime;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;
long abc; //assign some value to this long
String s = String.valueOf(abc); //convert long to string
DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss.S"); ///modify this according to your needs
DateTime dt = formatter.parseDateTime(date);https://stackoverflow.com/questions/24957882
复制相似问题