Skip to content

Commit 158cd7d

Browse files
Fix timestamp serialization to ISO-8601 format instead of array format
Co-authored-by: dmccoystephenson <21204351+dmccoystephenson@users.noreply.github.com>
1 parent e8c869a commit 158cd7d

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package com.accord.config;
2+
3+
import com.fasterxml.jackson.databind.ObjectMapper;
4+
import com.fasterxml.jackson.databind.SerializationFeature;
5+
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
6+
import org.springframework.context.annotation.Bean;
7+
import org.springframework.context.annotation.Configuration;
8+
import org.springframework.context.annotation.Primary;
9+
10+
/**
11+
* Jackson configuration to properly serialize Java 8 date/time types
12+
*/
13+
@Configuration
14+
public class JacksonConfig {
15+
16+
@Bean
17+
@Primary
18+
public ObjectMapper objectMapper() {
19+
ObjectMapper mapper = new ObjectMapper();
20+
// Register JavaTimeModule to handle Java 8 date/time types
21+
mapper.registerModule(new JavaTimeModule());
22+
// Serialize dates as ISO-8601 strings instead of arrays
23+
mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
24+
return mapper;
25+
}
26+
}

0 commit comments

Comments
 (0)