I have a form where I use a field LocalDate
that receives the value from a form mapped through Jackson
.
While JSON is:
Tue Jun 27 2017 00:00:00 GMT+0200 (ora legale Europa occidentale)
My LocalDate
variable is 2017-06-26
This is my pojo:
public class BookingForm {
private Integer building;
private Integer city;
private LocalDate date;
private String description;
private LocalTime endTime;
private List<Integer> externalUsers;
private List<Integer> internalUsers;
private String name;
private Room room;
private LocalTime startTime;
private List<ExternalUser> newExternalUsers;
//get and set method
And I have introduced Jackson for JDK8:
<!-- Jackson dependencies -->
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-hibernate5</artifactId>
<version>${jacksondatatype.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jdk8</artifactId>
<version>${jacksondatatype.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
<version>${jacksonjsr310.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.module</groupId>
<artifactId>jackson-module-parameter-names</artifactId>
<version>${jacksondatatype.version}</version>
</dependency>
With Date
instead of LocalDate
all work fine.
Is there a problem with timezone or what else?
UPDATE: This is my Spring configuration:
public MappingJackson2HttpMessageConverter jacksonMessageConverter(){
MappingJackson2HttpMessageConverter messageConverter = new MappingJackson2HttpMessageConverter();
ObjectMapper mapper = new ObjectMapper();
mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
//authomatic registration
mapper.findAndRegisterModules();
messageConverter.setObjectMapper(mapper);
return messageConverter;
}
is it possible to configure here?
I think your Jackson is set to use GMT and your BookingForm may be using something other like BST which is causing this