I just discovered a problem with a date field in my application. I have a date field that is indexed in Solr in UTC format. For instance, "parution_date": "2014-09-29T22:00:00Z",
. When I make request to Solr using a pivot, and I want to get this value, Solr converts my date to CET (I'm in Europe).
Here the date I received for the same document: Tue Sep 30 00:00:00 CEST 2014
.
As you see here, instead of keeping the date to its original format which is UTC, it converts the date CEST. I want to keep the UTC format because I using this field to research some documents.
For this request, I am using a facet pivot. Here is how, I get the results :
for(PivotField pv : pivotFields){
Date value = (Date) pv.getValue();
String parutionDate = formatDate(value, DateHelper.DD_MM_YYYY_FORMAT);
}
The getValue method, returns an object so I have to cast it to a Date object.
I see some solutions :
- When I am making a request to Solr, convert my CEST date to UTC, but I don't know how to do it for now. I am beginner at Solr.
- or keep my date to UTC formats.
What are the best solutions to deal with this issue? Any help would be appreciated.