Hi :)

I'm starting to use Solr and I'm facing a little problem with dates. My documents have a date property which is of type 'yyyyMMdd'.

To index these dates, I use the following code:

String dateString = "20101230";
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
Date date = sdf.parse(dateString);
doc.addField("date", date);

In the index, the date "20101230" is saved as "2010-12-29T23:00:00Z" ( because of GMT).

Now I would like to query documents which have their date property equals to "20101230" but I don't know how to handle this.

I tried the following code :

String dateString = "20101230";
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
Date date = sdf.parse(dateString);
SimpleDateFormat gmtSdf = new SimpleDateFormat("yyyy-MM-dd'T'HH\\:mm\\:ss'Z'");
String gmtString = gmtSdf.format(Date);

The problem is that gmtString is equals to "2010-12-30T00\:00\:00Z". There is a difference between the index value and the parameter value of my query : /.

I see that there might be something to do with the timezones during the date to string and string to date conversion but I can't find it.

Thanks,

Gary





Reply via email to