I recently discovered that Solr doesn't support negative years (i.e. BC) and I set about working on fixing it. It's just a formatting issue (date -> string), from what I see. I could just fix this but then I saw that we haven't yet moved on to the Java 8 java.time API (a derivative of Joda time), and I'd rather simplify Solr's date formatting & parsing code using this API instead of adding just one fix for something java.time already supports. I also see we annoyingly have 2 date utility classes: DateFormatUtil and DateUtil.
I started a quick hack to cut over DateFormatUtil's formatting to this one-liner: DateTimeFormatter.ISO_INSTANT.format(d.toInstant()); and similarly there's a one-liner for parsing. I'd love to just cut over to this but there are some slight differences we would see and I want to get people's opinion if any of these differences are a blocker: * Milliseconds are 0 padded to 3 digits if the milliseconds is non-zero. Thus 30 milliseconds will have ".030" added on. Our current formatting code does ".03". * Dates with years after '9999' (i.e. 10000 and beyond, >= 5 digit years) *must* have a leading '+' -- it is formatted with a "+" and if such a year is parsed it *must* have a "+" or there is an exception. Currently a '+' would yield an exception and there is no "+" emitted. * Of course as mentioned, currently we don't support negative years (resulting in invisible errors mostly); we'd get this for free. This stuff should matter so little to most apps that I hope there isn't dissent on my proposal. If there's a real reason to keep something consistent with current behavior, I'm sure we could complicate things further but it'd be great to simply use ISO_INSTANT exactly. See https://issues.apache.org/jira/browse/SOLR-1899 and sub-task SOLR-2773 (the 2nd one) specifically. -- Lucene/Solr Search Committer, Consultant, Developer, Author, Speaker LinkedIn: http://linkedin.com/in/davidwsmiley | Book: http://www.solrenterprisesearchserver.com