[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

error in svnClientAdapter command-line xml date parsing.

From: Jennifer Bevan <jen_at_alouysius.net>
Date: 2005-01-05 23:31:24 CET

Hi,
I believe there is an error in the svnClientAdapter command line xml date
parsing. Helper.java (r1184) uses a SimpleDateFormat to parse the XML
date, but does not set the time zone to be GMT -- but the XML document
parser converts the log message time (format is HH:mm:ss Z) to GMT.
So, I kept noticing a double-shift in my reported times. To test, I
committed
to my test repository at 1:08pm PST:

jen@bang:/tmp/hello <1113> svn log
------------------------------------------------------------------------
r21 | tester | 2005-01-05 13:08:33 -0800 (Wed, 05 Jan 2005) | 3 lines

But svnClientAdaptor's CmdLineLogMessage.getDate() kept telling
me that the commit occured at 5:08 AM the next day -- which is
twice the 8 hour offset. I narrowed it down to the xml parser shifting
it by 8 hours to GMT, and then Helper.java:convertXMLDate returning
that time as a local time (9:08pm PST, in my case), which of course
would then get
shifted by 8 hours the next time I printed it out as GMT.

So, I have a patch, of course. Now my reported dates match my
expected dates. Of course, there are some dependency issues here:
is anyone expecting the date returned in CmdLineLogMessage to
be a localized date? It would seem like there shouldn't be, but that's
why I'm posting here...

Thanks,
Jennifer Bevan

Index: Helper.java
===================================================================
--- Helper.java (revision 1184)
+++ Helper.java (working copy)
@@ -35,6 +35,7 @@
                new SimpleDateFormat("yyyy-MM-dd hh:mm:ss Z");
 
        // 2003-10-13T12:54:42.957948Z
+ // This formatter uses local timezone, not GMT.
        private static DateFormat xmlFormat =
                new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
 
@@ -74,12 +75,15 @@
        }
 
        static Date convertXMLDate(String date) {
- if (date == null)
- return null;
- try {
- return xmlFormat.parse(date);
- } catch (ParseException e1) {
- return null;
+ Date result = null;
+ if (date != null) {
+ try {
+
xmlFormat.setTimeZone(java.util.TimeZone.getTimeZone("GMT"));
+ result = xmlFormat.parse(date);
+ } catch (ParseException e1) {
+ System.out.println(e1.getMessage());
+ }
                }
+ return(result);
        }
 }
Received on Thu Jan 6 09:31:24 2005

This is an archived mail posted to the Subclipse Dev mailing list.