[Mulgara-dev] XSD Date/Time Corruption reproducible
Eric Brown
yogieric.dev at gmail.com
Thu Jan 25 20:59:20 UTC 2007
Hi Paul,
On Jan 25, 2007, at 12:27 PM, Paul Gearon wrote:
> I was about to comment that a one hour difference was too big a
> coincidence to ignore the possibility of a timezone (or DST)
> issue. This is despite the fact that other observed differences
> have been significantly different.
>
> I was also going to comment that the relevant code is in:
> src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/
> SPDateTimeImpl.java
>
> But then I thought it was just too lazy of me to not look at the
> code myself before posting.
>
> The problem would seem to be in encoding/decoding, so I tried
> pulling the relevant java files out, and into a test area where I
> could look at them in peace. I then wrote a test class, and found
> the following:
>
> String datestring = "1981-04-26T02:56:00";
> System.out.println("Normal form: " + datestring);
> SPDateTimeImpl dti = SPDateTimeImpl.newInstance(datestring);
> System.out.println("Lexical form: " + dti.getLexicalForm());
>
> Gives the following output:
> Normal form: 1981-04-26T02:56:00
> Lexical form: 1981-04-26T03:56:00
>
> Gak.
>
> When I change the original string to "1981-04-26T03:56:00" then the
> output becomes:
> Normal form: 1981-04-26T03:56:00
> Lexical form: 1981-04-26T03:56:00
>
> Double Gak.
>
> After looking at the internal data structures, I narrowed it down
> the parser in newInstance. Unfortunately, the bug here is in a
> third party date parser from Mouse Pushers (which I'd never heard
> of before today). If you try the following code:
>
> Date date = DateParser.parse(
> "1981-04-26T02:56:00.000",
> "yyyy-MM-dd'T'HH:mm:ss.SSS",
> Locale.getDefault());
> System.println(date.toString());
>
> Then the output is:
> Sun Apr 26 03:56:00 CDT 1981
>
> Note that the hour has changed from 2 to 3. It doesn't get changed
> when the time starts at 3:56. I suspect you will find that all of
> your problem dates will show up incorrectly from this parser.
>
> So it's not Mulgara's fault!!! :-)
>
> Unfortunately, there is no more recent version of this parsing
> library, so we either have to debug the source code ourselves
> ( http://www.mousepushers.com/java.html) or else we find/write
> another date parser. Anyway, I'm *supposed* to be working, so I
> have to leave it here until tonight.
You might want to look at joda. It seems very complete and under
active development. Don't know about performance.
http://joda-time.sourceforge.net/
Cheers,
Eric
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mulgara.org/pipermail/mulgara-dev/attachments/20070125/37a01bfe/attachment.htm>
More information about the Mulgara-dev
mailing list