christophstrobl / spring-data-solr-showcase

Sample Spring MVC Application demonstrating usage of Spring Data Solr.
Apache License 2.0
95 stars 85 forks source link

Overriding the Date Formatter in SolrTemplate #13

Closed sanyalpp closed 6 years ago

sanyalpp commented 6 years ago

Hello Chris,

I am facing a problem with the date time format. The dates are stored in Solr in the format as "yyyy-MM-dd'T'HH:mm:ss'Z'".

When I am using the solrTemplate.queryForGroupPage, I am getting the date as "Fri Dec 31 16:00:00 PST 1999"

When I query Solr directly I can see the data being returned in the ISO 8601 Zoned format.

I tried doing what you have mentioned in https://stackoverflow.com/questions/21345304/how-to-rounds-down-date-filter-query-using-spring-data-solr. But didn't get any result.

This is my field definition in @SolrDocument: @Indexed(name = "my_dt", type = "date") private String my_dt;

Please let me know.

sanyalpp commented 6 years ago

Ok Solved this by annotating the filed in this manner:

@JsonFormat(shape = JsonFormat.Shape.STRING, pattern ="yyyy-MM-dd'T'HH:mm:ss'Z'") @indexed(name = "my_dt", type = "date") 
private String my_dt;