I output a POJO from an azure function written with spring cloud function which contains a datetime type. I have tried it with instant where it was treated as a POJO:
"timestamp": {
"seconds": 1584229103,
"nanos" 0
}
I tried it as an OffsetDateTime and got:
"timestamp": {
"dateTime": {
"date": {
"year": 1970,
"month": 1,
"day": 19
},
"time": {
"hour": 8,
"minute": 3,
"second": 46,
"nano": 837000000
}
},
"offset": {
"totalSeconds": 0
}
}
I tried various things at the spring level like:
@Bean
public MappingJackson2MessageConverter configJacksonMessageConverter() {
final MappingJackson2MessageConverter mappingJackson2MessageConverter = new MappingJackson2MessageConverter();
ObjectMapper objectMapper = new ObjectMapper()
.registerModule(new JavaTimeModule());
mappingJackson2MessageConverter.setObjectMapper(objectMapper);
return mappingJackson2MessageConverter;
}
But they had no effect. Reading https://learn.microsoft.com/en-us/azure/azure-functions/functions-reference-java#pojos it sounds like azure-functions-java-worker is doing the final work of converting the pojo to json and it doesn't use jackson at all. How do I get a similar output to JavaTimeModule with automatic serialisation of values? Do I have to work with string outputs? I could find no documentation dealing with this and no examples.