Search code examples
springspring-bootelasticsearchlocaltime

LocalTime(00:01:002) turns to (24:00:02) after saving to ElasticSearch by Spring data elasticsearch repo


when I save the LocalTime object with Spring Data ElasticSearch repository interface, I find the data in ElasticSearch changed unexpectedly,the LocalTime with Value "00:01:01" changed to "24:01:01".

I use Java LocalTime to record the time period in a day , the value need to be save and retrieve from ElasticSearch by Spring Data ElasticSearch interface

 @JsonFormat(pattern = "kk:mm:ss", shape = JsonFormat.Shape.STRING)
 private LocalTime toTime;   

I expect that the value should nob be changed when I store it in ElasticSearch


Solution

  • Use pattern like HH:mm:ss instead of kk:mm:ss