Skip to content
Advertisement

Spring Data with Redis: How do I use a different LocalDateTime format or a different convertor?

I have data in my DB for field date with the following format: 2021-09-21 11:25:36. The Redis field is of type TEXT.

When I’m trying to read the data from date field from the DB, I get following exception:

JavaScript

How can I assign a different convertor to this field in my entity or annotate that my LocalDateTime format is different than what is being expected? My current assumption is that the issue resides in the missing ‘T’ between the date and the time, but I have little to no possibility to change the data from the DB.

Advertisement

Answer

I found the answer a bit later myself using RedisCustomConverters:

This bean is necessary:

JavaScript

in combination with this custom converter:

JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement