Mailing List Archive

DateField - dates before 1970
The method DateField.dateToString(Date date) throws an exception if the long
value of Date.getTime() is negative. Therefore, it is not possible to
'encode' dates that are prior to 1970. I think a limitation like this
should be clearly documented. Please let me know if I have missed something
here.

A possible work-around would be to add 200 years (or what ever is
*necessary*) worth of milliseconds to the value that is passed into
DateField.timeToString() and then subtract it from the return value of
DateField.stringToTime(). I'm going to try this, unless someone warns me
not to.

I am using lucene-1.2-rc1

Thanks for your consideration,

Philip

> Philip V. Ogren
> Medical Information Resources
> Mayo Clinic Rochester
> (507) 538-0167
> ogren@mayo.edu


--
To unsubscribe, e-mail: <mailto:lucene-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:lucene-user-help@jakarta.apache.org>
RE: DateField - dates before 1970 [ In reply to ]
Attached is a modified version of DateField. There are only 3 lines that
are modified:

line 69: private static long DATE_OFFSET = 6307200000000L; //200 years of
milliseconds = 200*365*24*60*60*1000
line 89: time = time + DATE_OFFSET;
line 106: return Long.parseLong(s, Character.MAX_RADIX) - DATE_OFFSET;

I'm new to Lucene and I realize this is probably the wrong list to send this
to. Please let me know if I am way out of line here. It seems like very
straightforward workaround - not necessarily a *good* solution.

-----Original Message-----
From: Ogren, Philip V.
Sent: Wednesday, November 14, 2001 8:06 AM
To: 'Lucene Users List'
Subject: DateField - dates before 1970



The method DateField.dateToString(Date date) throws an exception if the long
value of Date.getTime() is negative. Therefore, it is not possible to
'encode' dates that are prior to 1970. I think a limitation like this
should be clearly documented. Please let me know if I have missed something
here.

A possible work-around would be to add 200 years (or what ever is
*necessary*) worth of milliseconds to the value that is passed into
DateField.timeToString() and then subtract it from the return value of
DateField.stringToTime(). I'm going to try this, unless someone warns me
not to.

I am using lucene-1.2-rc1

Thanks for your consideration,

Philip

> Philip V. Ogren
> Medical Information Resources
> Mayo Clinic Rochester
> (507) 538-0167
> ogren@mayo.edu