In 3.6.1 i also got back a Date insance, now from 4.0 I receive also a String.
I don't like this, but I adapted my software now. Is there no way to change this behavior in the config? -----Ursprüngliche Nachricht----- Von: Shawn Heisey [mailto:s...@elyograg.org] Gesendet: Sonntag, 13. Januar 2013 07.53 An: solr-user@lucene.apache.org Betreff: Re: Question about dates and SolrJ On 1/12/2013 7:51 PM, Jack Park wrote: > My work engages SolrJ, with which I send documents off to Solr 4 which > properly store, as viewed in the admin panel, as this example: > 2013-02-04T02:11:39.995Z > > When I retrieve a document with that date, I use the SolrDocument > returned as a Map<String,Object> in which the date now looks like > this: > Sun Feb 03 18:11:39 PST 2013 > > I am thinking that I am missing something in the SolrJ configuration, > though it could be in how I structure the query; for now, here is the > simplistic way I setup SolrJ: > > HttpSolrServer server = new HttpSolrServer(solrURL); > server.setParser(new XMLResponseParser()) > > Is there something I am missing to retain dates as Solr stores them? Quick note: setting the parser is NOT necessary unless you are trying to connect radically different versions of Solr and SolrJ (1.x and 3.x/later, to be precise), and will in fact make SolrJ slightly slower when contacting Solr. Just let it use the default javabin parser -- it's faster. If your date field in Solr is an actual date type, then you should be getting back a Date object in Java which you can manipulate in all the usual Java ways. The format that you are seeing matches the toString() output from a Date object: http://docs.oracle.com/javase/6/docs/api/java/util/Date.html#toString%28%2 9 You'll almost certainly have to cast the object so it's the right type: Date dateField = (Date) doc.get("datefieldname"); Thanks, Shawn