[英]Date format with Spring Boot don`t work
I Put in my aplication.properties
: 我把我的
aplication.properties
:
spring.jackson.date-format=dd/MM/yyyy HH:mm:ss
And in my Application.java
: 在我的
Application.java
:
@Configuration
@EnableAutoConfiguration
@SpringBootApplication
@EnableConfigurationProperties
@ComponentScan
@EnableWebMvc
public class Application extends SpringBootServletInitializer
{
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(Application.class);
}
public static void main(String[] args) throws Exception {
SpringApplication.run(Application.class, args);
}
}
Then I create one method to return one Date
: 然后我创建一个方法来返回一个
Date
:
@RequestMapping(method = RequestMethod.GET, value = "/teste/")
public Date teste() {
return new Date();
}
So when I call this method I got this return: 所以当我调用这个方法时,我得到了这个回报:
1466081600310
1466081600310
and not the 而不是
16/06/2016 10:00:00 (today)
16/06/2016 10:00:00(今天)
this happen with another field in my objects. 这发生在我的对象中的另一个字段。
Hope you already found the reason. 希望你已经找到了原因。
I'm using Spring Boot 2.1.3, and encountered similar issue as well. 我使用的是Spring Boot 2.1.3,也遇到了类似的问题。 Then I found this po:
然后我找到了这个po:
https://github.com/spring-projects/spring-boot/issues/6642 https://github.com/spring-projects/spring-boot/issues/6642
which indicates the cause might be "@EnableWebMvc". 表示原因可能是“@EnableWebMvc”。
Hope it could help. 希望它可以帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.